Binding Luau (aka Roblox Lua) into C#
October 31, 2023
Tagged: Programming Tools
This will be a short one because I need to get back to other things, BUT I wanted to make a small post here to say that I just released a the first version of Luau.NET.
I had been interested in Luau since the first post announcing that it was going open source. I’ve never played Roblox or experimented with its creator tools, so my interest in it was less in that, but more that the language is currently secretly a major force in programming language learning for younger kids/teens, and so the idea of being able to transport that skill outside of Roblox felt really interesting.
Not only that, but the language itself is a workhorse, with lots of things possible both inside it and outside of it. So it isn’t just a toy language, but instead something that’s being constantly battle tested and user tested by millions of people around the world.
On top of that, Luau serves a really interesting proposition on top of that, which is how it sandboxes scripts. You give a tool like this to children (and people that make games for children), and people will definitely abuse whatever affordances you grant them. Luau is instead aggressively sandboxed, which makes it not only a great language for their use case, but also for general purpose UGC script authoring.
Most script mods for games need to ship DLLs and are prone to easy monkey-patching and abuse, and work effectively on the honor system. Instead, having a robust language for scripting with type safety, object access, etc., is the holy grail of mod scripting, and Luau seems to really be offering that!
So I took the time the past few days to try and get it working for C#. And I did! This was definitely a bit hard because I was juggling a few things I had never really dealt with in the past, both from trying to understand what was idomatic Lua and what was Luau specific, what functions had to be called, etc.
But after lots of trial and error (and some more Zig code!) I got all the bindings properly generating and also have the language building as a DLL (well, dylib for now). Not sure where I’m going to go with this next but wanted to just get something up as a proof of concept and see what the world does with it!
Published on October 31, 2023.
Tagged: Programming Tools