Skip to content

Getting Started

Syntax-Sculptor edited this page Nov 24, 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 include and calling its Init method:

local TestMod = RegisterMod("Palette Test Mod", 1)
local Palette = include("palette_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. You should only call Init once (usually inside of your mod's main.lua). Subsequent calls will result in an error.

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 Your First Particle Emitter

From here on out for the rest of the tutorials, we will have our particles use an image, particle.png. You can download the image here. Save the image in resources/gfx inside your mod. You're also free to change the name and location (as long as it's inside your mod's resources folder), though you will need to update each code snippet given.

You can also use any image you want, though for these tutorials, we recommend using a white image with a dimension of 32x32 pixels.

Note

While the 32x32 dimensions for particle images are not mandatory as you can just set the StartScale property of Particle Emitters if they look too big, the image must be a PNG and have a bit-depth of 32-bits, otherwise you will only see a black square in-game.

Once you've initialized Palette, creating your first Particle Emitter is straightforward. It can be done using the Palette:CreateParticleEmitter function, which takes in two arguments:

  • texturePath (string): The path to the particle's image relative to the mod's "resources" folder. The image must be a 32-bit PNG. An invalid path will cause an error.
  • position (Vector, optional): The position of the Particle Emitter, in world coordinates.

Below is an example that creates a Particle Emitter in the center of the room whenever you enter one:

local mod = RegisterMod("Palette Test", 1)
local Palette = include("palette_scripts.palette")

Palette:Init(mod)

mod:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, function()
    local position = Game():GetRoom():GetCenterPos()

    -- You may need to change the path based on what you named the image and where it's at!
    local emitter = Palette:CreateParticleEmitter("gfx/particle.png", position)
end)
2026-10-18.13-38-37.mp4

TADA! You created your first Particle Emitter. It's quite boring looking, but don't worry. We can easily customize Particle Emitters to give them tons of visual flair!

Particle Persistence

Just like most entities, you can store a reference to the Particle Emitter outside of a callback. However, as Particle Emitters can be destroyed at any point, you should call ParticleEmitter:IsDestroyed before interacting with it:

local emitter

mod:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, function()
    emitter = Palette:CreateParticleEmitter("gfx/particle.png", Vector(100, 100))
end)

-- A function you call later...
local function emitParticles()
    -- Spawns ten particles if the emitter hasn't been destroyed.
    -- Calling `Emit` on a destroyed emitter would cause an error.
    if emitter and not emitter:IsDestroyed() then
        emitter:Emit(10)
    end
end

By default, Particle Emitters are destroyed when leaving the run or changing rooms. However, this can be prevented by setting the PersistAcrossRooms field to true:

local emitter = Palette:CreateParticleEmitter("gfx/particle.png")
emitter.PersistAcrossRooms = true

When setting PersistAcrossRooms = true, Particle Emitters will continue to exist, even when entering new rooms. However, keep in mind that they can still be manually destroyed via ParticleEmitter:Destroy().

Adding Visual Flair

From the earlier example, you saw that the Particle Emitter looked quite boring! Fortunately, Palette exposes plenty of fields for Particle Emitters, allowing you to easily customize how the particles look. As a quick demonstration, let's have the Particle Emitter emit fast-moving green particles that fan out in a random spread. Here are some fields that allow you to do this:

  • StartSpeed (number): The initial speed of spawned particles. Default: 2
  • StartColor (KColor): The initial color of spawned particles. Default: KColor.White
  • StartDirection (Vector): The direction that spawned particles travel in. For example, setting it to Vector(1, 0) causes particles to move right. Default: (0, -1) (up).
  • DirectionSpread (number): How spread out particles are spawned relative to the emitter's StartDirection. Particle Emitters will pick a random angle between -DirectionSpread and +DirectionSpread. Default: 0
  • StartScale (Vector): The image's scale. This acts as a size multiplier. A value of (1, 1) would use the image's exact dimensions, (2, 1) would horizontally stretch the image 2x the width, and so on. Default: (1, 1)
local mod = RegisterMod("Palette Test", 1)
local Palette = include("palette_scripts.palette")

Palette:Init(mod)

mod:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, function()
    local position = Game():GetRoom():GetCenterPos()

    local emitter = Palette:CreateParticleEmitter("gfx/particle.png", position)
    emitter.StartSpeed = 10
    emitter.DirectionSpread = 25
    emitter.StartColor = KColor(0, 1, 0, 1)
    emitter.StartScale = Vector(0.95, 0.95)
end)

It's already looking much more interesting!

2026-10-18.14-10-30.mp4

...However, it looks predictable in some ways. Each particle has the exact same size, color, and speed, with only its direction varying thanks to DirectionSpread. Fortunately, this is no problem with Palette.

Palette makes it extremely easy for you to implement randomness! Many fields support either a fixed value or a range of values. To use a range, simply provide a table with this structure:

{
  Min = ...,
  Max = ...
}

Palette will randomly select a value between Min and Max whenever a particle spawns. For colors and vectors, the values are interpolated between the two endpoints.

From the above snippet, we can edit the code to give it a randomized size, color, and speed like this:

local mod = RegisterMod("Palette Test", 1)
local Palette = include("palette_scripts.palette")

Palette:Init(mod)

mod:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, function()
    local position = Game():GetRoom():GetCenterPos()

    local emitter = Palette:CreateParticleEmitter("gfx/particle.png", position)
    -- When a particle spawns, its speed is set to a number between 6 and 12.
    emitter.StartSpeed = { Min = 6, Max = 12 }
    emitter.DirectionSpread = 25
    -- The chosen color can range between a dark green and a light green.
    emitter.StartColor = { Min = KColor(0, 0.4, 0, 1), Max = KColor(0, 1, 0, 1) }
    -- The chosen size varies between (0.8, 0.8) and (1, 1).
    emitter.StartScale = { Min = Vector(0.8, 0.8), Max = Vector(1, 1) }
end)
2026-10-18.14-12-43.mp4

Now the particles look more natural with their randomized properties! Each particle receives its own randomized starting properties when spawned. These values remain fixed throughout its lifetime unless modified by other systems, which will be explained in later sections.

Example: Green Fountain

Using what we've learned on this page, here's a quick demonstration putting together everything that was learned. Before that, there are three additional fields worth knowing:

  • MaxParticles: Determines how many particles belonging to the Particle Emitter can be alive at once. Once that limit is reached, it won't be able to spawn additional particles until an existing one expires. Default: 100
  • ParticleRate: How many particles the Particle Emitter emits throughout one second. The particles spawned throughout the one second are evenly distributed. Default: 5
  • Lifetime: How many game frames the particle lasts for until it expires. You can either set it to a fixed number or a table with a Min and Max field. Default: 60

Tip

Remember! With Isaac, 30 game update frames is equivalent to one second! For example, setting Lifetime to 30 means particles last for exactly one second, assuming the game isn't paused or lagging.

To make our effects stand out, we'll create two different Particle Emitters. One of them will be fast moving bright-green geyser. The other one will be a slower, darker green, and more spread out effect. With these combined, we'll have a distinct fountain effect:

local mod = RegisterMod("Palette Test", 1)
local Palette = include("palette_scripts.palette")

Palette:Init(mod)

mod:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, function()
    local room = Game():GetRoom()
    local spawnPos = room:GetCenterPos()

    local centerEmitter = Palette:CreateParticleEmitter("gfx/particle.png", spawnPos)
    centerEmitter.MaxParticles = 150
    centerEmitter.ParticleRate = 85
    centerEmitter.Lifetime = { Min = 18, Max = 32 }
    centerEmitter.StartSpeed = { Min = 3.5, Max = 6.5 }
    centerEmitter.DirectionSpread = 20
    centerEmitter.StartScale = {
        Min = Vector(0.24, 0.24),
        Max = Vector(0.48, 0.48)
    }
    centerEmitter.StartColor = {
        Min = KColor(0.10, 0.60, 0.32, 0.65),
        Max = KColor(0.65, 1.00, 0.70, 0.95)
    }

    local outerEmitter = Palette:CreateParticleEmitter("gfx/particle.png", spawnPos)
    outerEmitter.MaxParticles = 110
    outerEmitter.ParticleRate = 45
    outerEmitter.Lifetime = { Min = 25, Max = 55 }
    outerEmitter.StartSpeed = { Min = 0.7, Max = 2.4 }
    outerEmitter.DirectionSpread = 75
    outerEmitter.StartScale = {
        Min = Vector(0.35, 0.35),
        Max = Vector(0.80, 0.80)
    }
    outerEmitter.StartColor = {
        Min = KColor(0.02, 0.28, 0.12, 0.18),
        Max = KColor(0.12, 0.70, 0.45, 0.42)
    }
end)
2026-10-18.14-41-26.mp4

Where Particles Draw

By default, particles render above grid entities and entities. However, you can change how an emitter's particles render by changing the RenderMode field. Below is a list of values it supports:

Value Description Note
"Floor" Particles render below every entity and grid entity. -
"BehindEntities" Particles render above grid entities and below normal entities. Currently only works on development builds for REPENTOGON (including Project Babylon). Using this on a live build will have particles render above both grid entities and entities.
"AboveEntities" Particles render above every entity and grid entity. This is the default value
"AboveHUD" Particles render above the HUD. -
"AbovePause" Particles render above the pause menu while it's open. Particles won't render while the pause menu is closed.
"MainMenu" Particles render above the main menu. Particles won't render in-game.

There it is, our first fountain! With very little code, we've already created an eye-catching particle effect. Despite that, we're still on the tip of the iceberg. Throughout the sections, we'll cover more complex features to truly make our particle effects stand out. But for now, that's the basics!

Lastly, this tutorial won't cover every single facet of what Palette has to offer. However, you can check out the API documentation on the sidebar to see more.

Clone this wiki locally