LuaContext: don't run console commands without a Lua state

Init() only runs on game load and Shutdown() nulls lua_ back out, but ImDebugger::Frame
draws the Lua console outside its PSP_IsInited() block, and whether the console is open
is persisted config. So opening it, exiting to the menu, and typing anything other than
the built-in clear/help/history dereferenced null.
This commit is contained in:
Henrik Rydgård committed 2026-08-31 12:22:28 +02:00
1 parent 98e8ffe7cd
commit bcd4f7e653
1 file changed
+8
+8
View File
@@ -98,6 +98,14 @@ void LuaContext::Print(LogLineType type, std::string_view text) {
}
void LuaContext::ExecuteConsoleCommand(std::string_view cmd) {
if (!lua_) {
// Init() only runs on game load and Shutdown() nulls this back out, but the ImDebugger draws
// the Lua console outside its PSP_IsInited() check - and whether it's open is persisted
// config, so it can be up with no game loaded at all.
Print(LogLineType::Error, "No Lua state - load a game first.");
return;
}
// TODO: Also rewrite expressions like:
// print "hello"
// to