Summary
Currently, any unhandled runtime Lua error (such as arithmetic on a nil value, passing a nil argument to C++ bound types like Vector2, or indexing a nil table entry) triggers the default lua_atpanic handler. This immediately crashes the entire editor (PANIC: unprotected error in call to Lua API) with Aborted (core dumped).
Because the editor auto-loads the last saved scene and script state on startup, a single Lua typo causes a continuous startup crash loop for the developer.
Expected Behavior
Runtime errors in user Lua scripts should be caught gracefully using lua_pcall or a custom panic/error handler block. The error should print to the editor's Console/Log panel with a standard Lua stack trace, allowing the user to fix the script in real time without the editor crashing.
Actual Behavior
The engine crashes immediately with:
"PANIC: unprotected error in call to Lua API (attempt to perform arithmetic on a nil value)
Aborted"
Steps to Reproduce
- Create a 2D scene with a Lua script component.
- In the
onUpdate(delta) function, attempt an operation involving an uninitialized/nil variable (e.g., pos.x = pos.x + (missing_var * delta) or entity:setPosition(Vector2(nil_var, 100))).
- Run the scene.
- Observe the editor crashing immediately to the desktop.
Proposed Solution
Wrap calls into the embedded Lua state inside lua_pcall rather than direct lua_call, and redirect error messages to the editor's log output instead of aborting the host process.
Summary
Currently, any unhandled runtime Lua error (such as arithmetic on a
nilvalue, passing anilargument to C++ bound types likeVector2, or indexing aniltable entry) triggers the defaultlua_atpanichandler. This immediately crashes the entire editor (PANIC: unprotected error in call to Lua API) withAborted (core dumped).Because the editor auto-loads the last saved scene and script state on startup, a single Lua typo causes a continuous startup crash loop for the developer.
Expected Behavior
Runtime errors in user Lua scripts should be caught gracefully using
lua_pcallor a custom panic/error handler block. The error should print to the editor's Console/Log panel with a standard Lua stack trace, allowing the user to fix the script in real time without the editor crashing.Actual Behavior
The engine crashes immediately with:
"PANIC: unprotected error in call to Lua API (attempt to perform arithmetic on a nil value)
Aborted"
Steps to Reproduce
onUpdate(delta)function, attempt an operation involving an uninitialized/nil variable (e.g.,pos.x = pos.x + (missing_var * delta)orentity:setPosition(Vector2(nil_var, 100))).Proposed Solution
Wrap calls into the embedded Lua state inside
lua_pcallrather than directlua_call, and redirect error messages to the editor's log output instead of aborting the host process.