LUA Implementation Limitations & Notes: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
(One intermediate revision by the same user not shown) | |||
Line 5: | Line 5: | ||
* Global Consts ("_G", "_VERSION" and "_MOONSHARP") | * Global Consts ("_G", "_VERSION" and "_MOONSHARP") | ||
* Table Iterators ("next", "ipairs" and "pairs") | *[[Global LUA Functions|Table Iterators]] ("next", "ipairs" and "pairs") | ||
* Strings | * Strings | ||
* [[Table|Tables]] | * [[Table|Tables]] | ||
Line 24: | Line 24: | ||
*If you run into a wall due to functions not being exposed to LUA, please leave feedback on what you would like to build with the mod API but can't due to current limitations! This helps inform future revisions of the mod API. | *If you run into a wall due to functions not being exposed to LUA, please leave feedback on what you would like to build with the mod API but can't due to current limitations! This helps inform future revisions of the mod API. | ||
== Old AS3 LUA version notes (no longer relevant) == | == Old LUFA (AS3 LUA) version notes (no longer relevant) == | ||
Old notes (largely outdated? Based on the old AS3 version) | Old notes (largely outdated? Based on the old AS3 version) | ||
Latest revision as of 05:49, 13 July 2023
Our LUA VM is based on MoonSharp, which implements (more or less) the LUA 5.2 specification.
Features
The following interpreter features are enabled:
- Global Consts ("_G", "_VERSION" and "_MOONSHARP")
- Table Iterators ("next", "ipairs" and "pairs")
- Strings
- Tables
- Basic ("assert", "collectgarbage", "error", "print", "select", "type", "tonumber" and "tostring")
- Math
- Bit32
Caveats
Some caveats to be aware of when writing LUA code for it:
- This page describing known differences in MoonSharp may be helpful, in particular differences in std lib.
- A LUA global is registered under the name 'this' to point to the LUA object that is executing the code.
- See GPS for a sample.
- However, as this is just a global variable and not an actual language keyword, if your code creates classes, 'this' will still point to the entity.
- Equality operator on entities, maps, locations, and other Underworld classes should be generally avoided currently
- This is because AS3 will return a new LUA table for each requested class. In future, these will be cached which should allow for accurate equality comparison. In the meanwhile, you can check locations equality by comparing if they both have the same RoomID and map.getName. Entity equality is trickier since many entities may share the same name.
- If you encounter unexpected bugs, post on discord with a link to some sample code to reproduce the bug.
- If you run into a wall due to functions not being exposed to LUA, please leave feedback on what you would like to build with the mod API but can't due to current limitations! This helps inform future revisions of the mod API.
Old LUFA (AS3 LUA) version notes (no longer relevant)
Old notes (largely outdated? Based on the old AS3 version)
Underworld's LUA VM is a modified version of the 2009 lufacode project. It implements a small subset of the LUA 5.1 specification. There's a lot of caveats to be aware of when writing LUA code for it:
|