Using SLua on the main grid

These are the steps to follow before starting to script in SLua:

  • Install the official LL “Second Life Viewer”, from:
    https://releasenotes.secondlife.com/viewer/26.5.0.40714792196.html
    This viewer has the option to edit SLua scripts, most of the other viewers haven’t got it yet.

  • Teleport to one of the nine regions that have SLua activated. It doesn’t work in the other regions:
  • Rez an object and add a new script as usual. The script editor has a “compiler” drop-down list, at bottom center. Choose “Lua”:
    • LSL on Mono : LSL, with “Mono” checked (the usual one).
    • LSL Legacy : LSL, with “Mono” unchecked.
    • LSL on Lua : LSL, but compiled into VM Luau instead of VM Mono.
    • Lua
  • 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") // LSL is ll.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.