Since now Luau (https://luau-lang.org/) from Roblox is open source. It would be an interesting option for Defold’s Lua scripting.
Last time I checked out Defold, Lua and the fact it lacks type checking is one of the main reasons I decide to move to other engine (I ended up writing my game in TypeScript and I am very happy with the decision, if you are interested, here’s my game’s Steam link: Industry Idle on Steam)
I wonder anyone here has (or plan to) give it a try? Any possibility of official support?
I did check that out (or maybe a similar project) And I have used the underlying TypeScript to Lua compiler for other Lua modding projects. The general problem with transpiling is that often time I need to go to the transpiled file for debugging - which can get annoying very quickly. Also I am not sure whether the project is production ready - I don’t think the project has 100% type coverage for the engine code?
Parts of the Lua 5.x standard library are unsafe. Some of the functions provide access to the host operating system, including process execution and file reads. Some functions lack sufficient memory safety checks. Some functions are safe if all code is untrusted, but can break the isolation barrier between trusted and untrusted code.
The following libraries and global functions have been removed as a result:
io. library has been removed entirely, as it gives access to files and allows running processes
package. library has been removed entirely, as it gives access to files and allows loading native modules
os. library has been cleaned up from file and environment access functions (execute, exit, etc.). The only supported functions in the library are clock, date, difftime and time.
debug. library has been removed to a large extent, as it has functions that aren’t memory safe and other functions break isolation; the only supported functions are traceback.
dofile and loadfile allowed access to file system and have been removed.
These features are cool to have deleted if you want to make a game like Roblox, but not when making games where you trust your code and want access to these functions.
When initializing the default globals table, the tables are protected from modification:
All libraries (string, math, etc.) are marked as readonly
The string metatable is marked as readonly
The global table itself is marked as readonly
In other word, no monkey patching of builtin functions.
Seems like Luau would be a great fit if you want to make a game like Roblox which is itself a game development / publishing platform, or you want to make a game which is very mod friendly but also has security better built in.
Even though Luau and Defold Lua has some differences - I believe the high-level design goal is the similar. As a “scripting” language within an engine (or a game), some sandbox is needed. For example, both have restrictions on io and os library. Luau might be more restrictive than Defold Lua.
That being said, I am happy that the team is aware of this project. I think Lua could definitely benefit from a type checker (like TypeScript to JavaScript)
Defold now supports transpiling and you can already use Teal if you’re interested in a type-safe alternative to plain Lua. It still lacks several useful features, but I hope it will improve over time.
Yes, we found that Luau was a no-go as it is not a replacement for Lua. It lacks some moduled (e.g. io) and debug module doesn’t work the same. Also, it is not ABI compatible, and they have no intention of having that as a goal.