-
Notifications
You must be signed in to change notification settings - Fork 0
Particle
KabanFriends edited this page Dec 9, 2022
·
9 revisions
Particle
s are objects used to register custom particles. You can get a new particle object by calling particle.new()
.
Upon creating a new particle object, you can edit the following properties before registering the particle.
- The X coordinate of the top-left point in the
particles.png
texture. - Assuming
particles.png
is 256x256 pixels, this value responds to the actual pixel coordinates.
- The Y coordinate of the top-left point in the
particles.png
texture. - Assuming
particles.png
is 256x256 pixels, this value responds to the actual pixel coordinates.
- The texture width of this particle.
- Assuming
particles.png
is 256x256 pixels, this value responds to the actual pixel coordinates.
- The texture height of this particle.
- Assuming
particles.png
is 256x256 pixels, this value responds to the actual pixel coordinates.
- Red component of the RGB color to tint the particle texture.
- The value must be between 0 and 255.
- Blue component of the RGB color to tint the particle texture.
- The value must be between 0 and 255.
- Green component of the RGB color to tint the particle texture.
- The value must be between 0 and 255.
- Determines how many frames of animation will be played over the particle's lifespan (faster life, faster animation).
- Frames are always the same size as each other and are stored left-to-right in
particles.png
.
- How many particles are spawned every time you use
player.playParticle( ... )
.
- How large in "pixel" units the particle is. 8 is the size of a player's head. You are allowed to be as precise as half a pixel, therefore the smallest possible size is 0.5.
- How much the particle can randomly vary in size. 1 means 100% variation and 0 means 0% variation.
- Allows the particles to spawn randomly around the point they were told to spawn at.
- A spread of "0.5" is equal to the width of a full block (because the spread goes both ways).
- How fast this particles moves away from the origin.
- Gravity value adds to the up/down speed of the particle over time.
- For example, -1 means that the particle will float up.
- Time in seconds this particle is allowed to live at most.
- Depending on the collision options below, particles might disappear sooner than specified in this field.
- How much the particle's lifespan can randomly vary. 1 means 100% variation, 0 means 0% variation.
- If true, the particle will always have its original brightness, even in dark environments.
- If true, the particle disappears if it hits a solid floor (What counts as "solid" are determined in the fields listed below)
Particles can be registered and unregistered using following functions. particle
is a constant variable that can be accessed from anywhere.
- Returns a new instance of particle table. See above for the properties you can edit.
- Registers a particle table that was created using
particle.new()
, with the given name. You can register up to 256 particles. - Note that this will send the particle data to all players in the level, which might cause lags when used on loop.
- Unregisters a particle by its name, and frees up the internal space taken by that particle.
local par = particle.new()
par.x = 0
par.y = 0
par.width = 10
par.height = 10
par.tintRed = 255
par.tintGreen = 163
par.tintBlue = 190
par.frameCount = 8
par.particleCount = 1
par.size = 8
par.sizeVariation = 0.5
par.spread = 0.5
par.speed = 0.25
par.gravity = -1
par.lifetime = 0.5
par.lifetimeVariation = 0
par.expireUponTouchingGround = false
par.collideSolid = false
par.collideLiquid = false
par.collideLeaves = false
par.fullBright = true
particle.register("heart", par)
player.playParticle("heart", player.x, player.y, player.z) -- Plays the registered particle effect