The particle component is the Computronics particle emitter card. It spawns particle effects at positions relative to the host device and optionally gives them randomized or explicit velocity.
- Repository:
computronics - Component name:
particle - Typical host: Computronics particle card in a supported OC host
local component = require("component")
local particle = component.particle- Default maximum allowed range from the host is
Config.FX_RANGE, which is256by default. - If
FX_RANGEis negative, the source disables the distance check. - Energy cost is
Config.FX_ENERGY_COST * distance. - The default energy coefficient in the source is
0.2.
- Syntax:
particle.spawn(name, x, y, z[, defaultVelocity])particle.spawn(name, x, y, z[, vx, vy, vz])
- Returns:
- Success:
true - Failure:
falseorfalse, reason
- Success:
- Purpose: Spawns one particle effect at coordinates relative to the host.
Parameters:
name:string: particle name.x:number,y:number,z:number: relative offsets from the host position.defaultVelocity:numberoptional: gaussian spread scale used to generate randomized velocity.vx:number,vy:number,vz:numberoptional: explicit velocity components.
Behavior:
- The particle name may not exceed
Short.MAX_VALUEcharacters. - Position offsets are clamped to
-65536through65536. - Distance is computed from the relative offset vector.
- If the distance exceeds the configured maximum, the callback returns
false, "out of range". - If the name is too long, it returns
false, "name too long". - If the connector cannot pay the energy cost, it returns
false. - With only
defaultVelocity, the final velocity isdefaultVelocity * gaussianRandom()for each axis. - With all three velocity components supplied, those exact values are used.
Example:
assert(particle.spawn("smoke", 0, 1, 0, 0.02))
assert(particle.spawn("reddust", 0, 1, 0, 0, 0.05, 0))componentcomputronics-computronics-explode