Using SLua on the main grid
These are the steps to follow before starting to script in SLua:
-
Install the “Second Life Project Lua Editor” viewer, from:
https://releasenotes.secondlife.com/viewer/26.1.0.23768336784.html
This is a different viewer, with a different icon, than the “Second Life Viewer”. We can keep our usual viewer for the main grid and use this one for the beta grid. - Teleport to one of the nine regions that have SLua activated. It doesn’t work in the other regions:
- Lua Beta Landing
- Lua Beta Porridge
- Lua Beta Eraserhead
- Lua Beta Glass
- Lua Beta Void (this region is mostly water)
- Lua Beta Anderson
- Lua Beta Sausage
- Lua Beta Nicoise
- Lua Beta IsNeat
- Rez an object and add a new script as usual. The script editor has a “compiler” drop-down list, at bottom center. Choose “SLua”:
- LSL Legacy (LSO2) : LSL, with “Mono” unchecked.
- LSL Mono : LSL, with “Mono” checked (the usual one).
- LSL 2025 VM : LSL, but compiled into VM Luau instead of VM Mono.
- SLua
- All the LL functions exist in SLua with the same name, but with a “.” added between “ll” and the name of the function:
llSay(0, "Hello world") // LSLisll.Say(0, "Hello world") -- SLua.
- About the editor, some things to keep in mind:
- Some errors are not detected when compiling, we will get them in an error window, which sometimes opens behind the editor window. If the script does nothing after compiling, move the editor window to check.
- Coloring and highlighting do not work perfectly.
-
Some common runtime errors and what to check first (especially when we are new to SLua):
- attempt to call a nil value
- Check typos, or missing . in a LL function, on the left of ().
- attempt to perform arithmetic (add) on string
- Check use of .. (not +) to concatenate strings.
- attempt to index nil with …
- Check typos on the left of [].
- attempt to call a table value
- Check use of [] (not ()) to index a table.
- In general, if the error is about nil, check typos.
- attempt to call a nil value