Expand description
Test harness running Lua scripts outside of the game.
Scripts run in Lua 5.1, the version the games use, together with the real script libraries of the game
(script/_lib) and, optionally, the vanilla scripts of a campaign. What the game’s C++ side provides is
emulated by engine.lua: objects typed after the scripting docs that record every call made on them.
A test file registers tests with rpfm.test(name, function). Its top-level code runs before the game
boots, so the world it sets up (rpfm.faction { key = "...", is_human = true }) exists when the scripts
start. Each test then runs in its own Lua state, after the libraries, the mods of the tested packs and the
first tick have run, so tests can’t affect each other.
Scripts are sandboxed: they can’t run programs, load native code or touch files outside of memory.
Structs§
- LuaSave
- Values the scripts of a campaign save when the game saves it.
- LuaScripts
- Scripts the harness can load, by path.
- LuaTest
Options - Options of a test run.
- LuaTest
Report - Results of running a test file.
- LuaTest
Result - Result of a test.
Enums§
- LuaSaved
Value - A value saved by the scripts. The game saves numbers as integers, and doesn’t save other types.
Functions§
- run_
tests - This function runs the tests of a test file.
- save_
campaign - This function boots a campaign and saves it, like the game does when it builds the campaign’s startpos.