Particle
Represents a particle that can be spawned and modified
Obtained by indexing the ParticleAPI
Exists as an object-oriented alternative to particles:addParticle()
For the examples on this page assume:
myParticle = particles["explosion"]
spawn()
Spawns this particle with the current properties
spawn()
Returns:
Type | Description |
---|---|
Particle | Spawns the particle in the world |
Example:
myParticle:spawn()
setPos()
Aliases: pos()
Sets this particle position
The position is given in world coordinates
- Overload 1
- Overload 2
Example:
-- player position example
myParticle:setPos(player:getPos())
-- model part position example
myParticle:setPos(modelpart:partToWorldMatrix():apply())
getPos()
Gets this particle position
getPos()
Returns:
Type | Description |
---|---|
Vector3 | Gets the position the particle is at |
Example:
myParticle:getPos()
setColor()
Aliases: color()
Sets this particle's color, values must be between 0 and 1
Accepts an alpha value, but most particles do not support it
Default RGBA of 1
- Overload 1
- Overload 2
- Overload 3
setColor(rgb)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rgb | Vector3 | The RGB color applied to the particle | vec(1,1,1) |
Returns:
Type | Description |
---|---|
Particle | Returns the particle for chaining |
Example:
myParticle:setColor(1, 0, 1)
getColor()
Gets this particle color
getColor()
Returns:
Type | Description |
---|---|
Vector4 | Gets the RGBA color applied to the particle by setColor |
Example:
myParticle:getColor()
setScale()
Aliases: scale()
, setSize()
, size()
Sets this particle scale
setScale(scale)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scale | Number | Sets the scale of both axes of the particle | 1 |
Returns:
Type | Description |
---|---|
Particle | Returns the particle for chaining |
Example:
myParticle:setScale(2)
getScale()
Aliases: getSize()
Gets this particle scale
getScale()
Returns:
Type | Description |
---|---|
Number | Gets the scale of the particle |
Example:
myParticle:getScale()
setVelocity()
Aliases: velocity()
Sets the velocity of this particle
The velocity is given in world coordinates
- Overload 1
- Overload 2
Example:
myParticle:setVelocity(0, 5, 0)
getVelocity()
Gets the velocity of this particle
getVelocity()
Returns:
Type | Description |
---|---|
Vector3 | Gets the velocity of the particle |
Example:
myParticle:getVelocity()
setLifetime()
Aliases: lifetime()
Sets this particle lifetime, which is how many ticks this particle should stay in the world
setLifetime(lifetime)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lifetime | Integer | How long the particle will stay in the world in ticks | The default lifetime of the particle |
Returns:
Type | Description |
---|---|
Particle | Returns the particle for chaining |
Example:
myParticle:setLifetime(100)
getLifetime()
Gets this particle current lifetime
getLifetime()
Returns:
Type | Description |
---|---|
Integer | Gets how long the particle will stay in the world in ticks |
Example:
myParticle:getLifetime()
setPower()
Aliases: power()
Multiplies the particle's velocity every time it's run
setPower(power)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
power | Number | - | - |
Returns:
Type | Description |
---|---|
Particle | Returns the particle for chaining |
Example:
myParticle:setPower(2)
getPower()
Gets the last number passed into setPower, but not the total power of the particle
getPower doesn't get the particle's actual power, but the number last passed into setPower
getPower()
Returns:
Type | Description |
---|---|
Number | Gets the power of the particle |
Example:
myParticle:getPower()
setGravity()
Aliases: gravity()
Sets the strength of the particle's gravity
setGravity(gravity)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gravity | Number | Sets the strength of the particle's gravity | 1 |
Returns:
Type | Description |
---|---|
Particle | Returns the particle for chaining |
Example:
myParticle:setGravity(5)
getGravity()
Gets this particle gravity
getGravity()
Returns:
Type | Description |
---|---|
Number | Gets the strength of the particle's gravity |
Example:
myParticle:getGravity()
setPhysics()
Aliases: physics()
Sets if this particle has physics
setPhysics(physics)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
physics | Boolean | Boolean that turns physics on if true, and turns physics off if false | true |
Returns:
Type | Description |
---|---|
Particle | Returns the particle for chaining |
Example:
myParticle:setPhysics(false)
hasPhysics()
Gets if this particle has physics
hasPhysics()
Returns:
Type | Description |
---|---|
Boolean | Gets if this particle has physics |
Example:
myParticle:hasPhysics()
remove()
Removes this particle from the world
remove()
Returns:
Type | Description |
---|---|
Particle | Returns the particle for chaining |
Example:
myParticle:remove()
isAlive()
Checks if this particle is not flagged for removal
isAlive()
Returns:
Type | Description |
---|---|
Boolean | Returns if the particle is alive |
Example:
myParticle:isAlive()