Skip to content

Creating your first light

GLide KS edited this page May 22, 2026 · 8 revisions

Before starting, you'll require at least basic lua knowledge do follow these steps, please reffer to Lua (SRB2 Wiki) in order to learn about this programming language and SRB2's functions and features.

However, feel free to copy any code shown here and give it some trial and error.

On this guide, we're using a lot the term "Corona" which is generally used to refer these lights back in SRB2 Final Demo

First steps

Make a blank lua script file, it could be inside your addon or just standalone.

To define and register an object to make it have a corona, we're using a table named LightObjects which tells Lighting System which objects will gonna have a corona.

We must make sure this table exists globally first, so in your first line of your script must have the following code:

if not LightObjects then rawset(_G, "LightObjects", {}) end

Defining the object

Your object must exists first. In case to apply it to a custom object and want to create one, please refer to Custom Object Tutorial in order on how to make your custom object.

For this example, we're giving a corona for MT_BLUECRAWLA (Blue Crawla). This is a basic usage of how the definition looks like:

if not LightObjects then rawset(_G, "LightObjects", {}) end

LightObjects[MT_BLUECRAWLA] = {
    color = SKINCOLOR_BLUE,
    scale = FU,
    alpha = FU
}

color, scale, and alpha are fields available to use for Lighting System, and lets you specify visual properties for the corona. However, writing some of these values are not mandatory since Lighting System fields has default values.

For example, scale and alpha has by default FRACUNIT or FU in short, so I don't need to write it up in the table.

See usage and more in List of available fields

Now open SRB2 and load Lighting System and your script. With this example, this is how it looks in game:

crawla1

Nice! we made our first light for our object. But wait! we could make it more interesting. let's modify it a bit.

if not LightObjects then rawset(_G, "LightObjects", {}) end

LightObjects[MT_BLUECRAWLA] = {
    color = SKINCOLOR_BLUE,
    flicker = true,
    floorlight = true
}

flicker will make the corona always flicker (duh!), and floorlight will make the object spawn another corona but on the ground and as a splat instead.

In-game:

srb20025

And that's it! congratulations you've made your first corona for your object. You can always take a look in Vanilla.lua for better references to see how definitions are made.

Clone this wiki locally