Re: Lua scripting in OpenMW
Posted: 29 Dec 2020, 00:37
Progress report
A month ago I turned from discussions about Lua to the actual coding. Now it is time to talk about the progress.
Most of the main concepts (sandboxing, global/local/player scripts, handlers, events) are already implemented.
I think I've managed to build a clean and flexible basis that will be easy to extend. The code is here.
For now there is only a minimal API that I use to check interactions between local and global scripts.
Examples
I've updated the examples from my previous post to make it consistent with the part that is already implemented.
Here are also the scripts that I use for testing (and they actually work unlike the examples above): CI builds
At the moment there are only Debian CI builds.
Builds for other platforms will be available as soon as somebody adds prebuilt LuaJIT-2.1.0-beta3 to openmw-deps repo. I can barely imagine how C++ developers live in non-linux world, so I need help with it .
Tests
All the stuff in components/lua is covered by tests.
Testing apps/openmw/mwlua is tricky because it requires the whole engine to run. In the future I plan to make a set of Lua scripts to test every command in Lua scripting API, and run it automatically on the example-suite data.
Todo
List of things that should be done next:
A month ago I turned from discussions about Lua to the actual coding. Now it is time to talk about the progress.
Most of the main concepts (sandboxing, global/local/player scripts, handlers, events) are already implemented.
I think I've managed to build a clean and flexible basis that will be easy to extend. The code is here.
For now there is only a minimal API that I use to check interactions between local and global scripts.
Examples
I've updated the examples from my previous post to make it consistent with the part that is already implemented.
Here are also the scripts that I use for testing (and they actually work unlike the examples above): CI builds
At the moment there are only Debian CI builds.
Builds for other platforms will be available as soon as somebody adds prebuilt LuaJIT-2.1.0-beta3 to openmw-deps repo. I can barely imagine how C++ developers live in non-linux world, so I need help with it .
Tests
All the stuff in components/lua is covered by tests.
Testing apps/openmw/mwlua is tricky because it requires the whole engine to run. In the future I plan to make a set of Lua scripts to test every command in Lua scripting API, and run it automatically on the example-suite data.
Todo
List of things that should be done next:
- Saving/Loading scripts state (it will affect saves format).
- Get a list of global scripts to run from omwgame/omwaddon (currently "test.lua" is hardcoded). Data files format will not change - I am going to reuse the same way how MWScript stores list of global scripts for auto start.
- Extend current "minimal API" to "minimal valuable API" (just a few commands, but something useful).
- Write documentation for Lua scripting.