r/lua • u/slhamlet • 19d ago
Discussion We lead Lua scripting implementation for Second Life -- Ask Us Anything!
EDIT, Nov 12: Thanks everyone for the great questions! Will do another AMA soon-ish as Lua gets closer to official launch in SL!
Hi /lua! We’re Kyle (u/KyleLindenSL), Harold (u/HaroldCindy/) and Hamlet (u/SLHamlet) of Linden Lab, the company which publishes the long-running user-created virtual world Second Life.
We’re currently updating the platform to run Lua scripts and are excited to see what Lua developers (and Luau creators from Roblox) build with it in SL.
For background, Second Life has been online a bit longer than Roblox and while we have a smaller user base, SL is still a very active virtual world, and has a large ecosystem of community creators who sell their virtual content (fashion, animations, vehicles, games, etc.) as a side hustle or a full-time income.
Here’s more info about what we’re doing with Lua on 80 Level: https://80.lv/articles/second-life-wants-its-23-year-old-world-to-be-a-modern-game-platform
And a feature breakdown on our site: https://secondlife.com/create#scripting
Lua is now in live beta in SL if you want to check it out. Just need to install SL and teleport here: https://maps.secondlife.com/secondlife/Lua%20Beta%20Landing/121/141/23
We’re hoping Lua will help modernize SL as a UGC platform and grow the economy.
So if you’re curious… ask us anything! (We’ll be checking this thread over the next few days.)
View all comments
Show parent comment
6
u/HaroldCindy Linden Labs Dev 18d ago
To add more detail to this, the content creation flow in Second Life imposes a lot of different requirements that most other users of a scripting engine would not need, and these were easiest to implement with Lua (specifically Luau). Unlike Roblox or most other UGC platforms, scripting is done live in-world, there is no separate editor interface. Additionally, users are generally allowed to write scripts that run on their own avatar's "attachments" that continue to run in others' worlds.
Scripts in Second Life have also historically supported objects roaming across world instances without any explicit (de)serialization step for script state. When a scripted object crosses a region border, scripts have their runtime state transparently wound up by the server, and it is shipped to the new region. The receiving region deserializes the script runtime state, and execution continues as if nothing happened (at least, that's the intent!)
This means that we need a scripting runtime that allows lightweight sandboxing (to prevent users messing with each others' scripts or the world itself), is able to prevent resource abuse (via memory limits and script runtime limits that inject yields when a script runs too long) and that uses a language creators like. The ability to transparently transfer script state across is something I've only seen in a handful of Minecraft mods and Second Life's existing scripting system, so a scripting engine that would be flexible enough to implement this was needed.
As you can see from the matrix in the above linked FAQ, Luau was the only one that really satisfied all of those constraints. Having been working with Luau for 3 years at this point, I can confidently say that Luau was the right choice. I had done some OpenResty work in the past, but I gained a lot of appreciation for Lua's elegance, particularly metatables and their associated VM implementation simplicity throughout this project.
If you're part of a small team with a product where user scripting is integral to the experience, Luau makes it very painless to write the hooks you need for any kind of unusual integration needs that you might have. It helps the lot that there's a lot of talented people at Roblox working on Luau, and that Roblox's scripting needs aren't entirely dissimilar from Second Life's.
If you'd like to see more about the nuts-and-bolts of how those integration needs were addressed, Second Life's Luau VM fork called "SLua" is open source at https://github.com/secondlife/slua. SLua's diff from upstream Luau is intentionally kept small to not fragment the ecosystem, but there's quite a lot of logic related to individual scripts' runtime / memory limits and script state serialization that might be interesting to people.