Conversation
- Introduced Lua scripting support, enabled by default, with options to disable via CMake. - Updated `CMakeLists.txt` to include Lua detection and linking. - Enhanced `scripts/compile_engine.sh` to accept a `lua` flag for enabling Lua during build. - Added Lua compatibility header and debug functions for script management. - Implemented commands for script reloading, listing, and dumping in the Lua environment. This addition allows for more flexible scripting capabilities within the engine, enhancing modding potential and runtime script management.
- Updated `CMakeLists.txt` to enhance Lua package detection by removing duplicates and improving the search logic for Lua libraries. - Modified `lua_debug.c` to introduce a truncation flag for the script dump command, allowing for more accurate handling of output when exceeding the maximum entry limit. These changes streamline the Lua integration process and enhance the debugging experience for Lua scripts.
- Updated `CMakeLists.txt` to include additional Lua hint paths for Windows and improved error messaging for missing Lua headers/libraries. - Modified GitHub Actions workflow to install Lua 5.5 and its development libraries on Ubuntu and macOS environments, ensuring Lua support is available during builds. These changes improve the integration and detection of Lua scripting support across different platforms.
- Changed the installation of Lua from version 5.5 to 5.4 in the GitHub Actions workflow for both Ubuntu and macOS environments. - Adjusted the installation command to reflect the updated Lua version and its development libraries. These modifications ensure compatibility with the latest Lua features and maintain consistency across build environments.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7e2db25de0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| Com_Printf( "Lua: globals (limit %d)\n", maxEntries ); | ||
| while ( lua_next( s_luaState, -2 ) != 0 ) { | ||
| const char *keyName = lua_tostring( s_luaState, -2 ); |
There was a problem hiding this comment.
Preserve iterator key type while dumping globals
script_dump calls lua_tostring on the key before advancing lua_next, which mutates non-string keys (for example numeric keys) into strings; on the next iteration this can trigger Lua's "invalid key to 'next'" path and abort the dump (and potentially the process, since this call is not protected). This shows up as soon as a script stores any non-string key in _G.
Useful? React with 👍 / 👎.
| return qfalse; | ||
| } | ||
|
|
||
| if ( lua_pcall( s_luaState, 0, LUA_MULTRET, 0 ) != LUA_OK ) { |
There was a problem hiding this comment.
Drop unused Lua chunk return values after load
Each lua_pcall(..., LUA_MULTRET, ...) keeps all return values from the loaded chunk on the VM stack, but the loader never consumes them; module-style scripts that return tables/functions will therefore accumulate persistent stack references and memory across loads. Since these return values are not used anywhere, this creates avoidable state growth in long-running sessions.
Useful? React with 👍 / 👎.
No description provided.