Skip to content

Getting Started

Syntax Sculptor edited this page Oct 16, 2026 · 12 revisions

Initializing Palette

If you haven't already, make sure you have the latest version of Palette downloaded and saved somewhere inside your mod's folder.

Once you have Palette downloaded, you can initialize its systems by loading the script using require and calling its Init method:

local TestMod = RegisterMod("Palette Test Mod", 1)
local Palette = require("test-mod-scripts.palette") -- Change the directory based on where you saved Palette.

Palette:Init(TestMod)

From there, Palette will register the callbacks needed to manage the particles.

Warning

It's a good idea to put palette.lua inside of a folder with a unique name relating to your mod in order to prevent potential conflicts in the case two mods use different versions of Palette. For example, if your mod is named "More Penny Trinkets", you could name the folder "more-penny-trinkets-scripts". Renaming palette.lua to something unique works too.

Creating a Particle Emitter

Warning

Make sure that you have called Palette:Init before creating a Particle Emitter, otherwise you will get an error.

A Particle Emitter is an object responsible for spawning and managing particles. To create one, you can call Palette:CreateParticleEmitter. The method takes in two arguments:

  • texturePath (string): The path to the image used for each particle, relative to the mod's resources folder. For example: "gfx/testParticles.png". The image must have a bit-depth of 32 bits.
  • position (Vector or Vector3, optional): The position where particles will spawn. By default, Palette uses world-space coordinates. If omitted, the position defaults to (0, 0, 0).

For example:

-- Adjust the texture path based on where the image is saved.

local emitter = Palette:CreateParticleEmitter("gfx/testParticle.png", Vector(100, 100))

Palette allows the use of traditional Vectors and an object known as Vector3, which supports the Z coordinate. We'll cover this in greater detail in Coordinate Systems and Vectors.

Once created, the emitter will automatically begin spawning particles according to its emission settings. You should see something similar to the following, depending on the texture:

By default, emitters render their particles using the world space. However, you can render them using screen-space coordinates by setting emitter.IsWorldSpace to false:

local emitter = Palette:CreateParticleEmitter("gfx/testParticle.png", Vector(100, 100))
emitter.IsWorldSpace = false

Configuring a Particle Emitter

Palette supports countless properties for configuring the visual behavior of the particles. Here are some right off the bat:

Property Expected Data Type Description
StartColor KColor The initial color of the particles.
ParticleRate number How many particles spawn per second.
Lifetime integer How many update frames a particle lives before it's removed.
StartSpeed number Initial movement speed, measured in units per frame.
StartDirection Vector or Vector3 The direction particles travel when spawned.
MaxParticles integer Maximum number of particles that can exist simultaneously.

For example, the following snippet creates a Particle Emitter that diagonally emits green particles towards the bottom right.

local emitter = Palette:CreateParticleEmitter("gfx/testimg.png", Vector(250, 250))
emitter.ParticleRate = 10
emitter.StartSpeed = 5
emitter.StartDirection = Vector(2, 2)
emitter.StartColor = KColor(0, 1, 0, 1)

Clone this wiki locally