diff --git a/stepmania/src/ActorCommands.cpp b/stepmania/src/ActorCommands.cpp index 083d1adb9c..33b9199fd3 100644 --- a/stepmania/src/ActorCommands.cpp +++ b/stepmania/src/ActorCommands.cpp @@ -58,6 +58,12 @@ void ActorCommands::PushSelf( lua_State *L ) const void ActorCommands::Register( const Commands& cmds ) { + if( cmds.v.size() == 0 ) + { + m_sLuaFunctionName = "nop"; + return; + } + // TODO: calculate a better function name, or figure out how // to keep a pointer directly to the Lua function so no global // table lookup is necessary. @@ -130,9 +136,12 @@ void ActorCommands::Unregister() ASSERT( m_sLuaFunctionName.size() ); - lua_pushstring( LUA->L, m_sLuaFunctionName ); - lua_pushnil( LUA->L ); - lua_settable( LUA->L, LUA_GLOBALSINDEX ); + if( m_sLuaFunctionName != "nop" ) + { + lua_pushstring( LUA->L, m_sLuaFunctionName ); + lua_pushnil( LUA->L ); + lua_settable( LUA->L, LUA_GLOBALSINDEX ); + } m_sLuaFunctionName = ""; } diff --git a/stepmania/src/LuaManager.cpp b/stepmania/src/LuaManager.cpp index 0412cec1a7..b467899d88 100644 --- a/stepmania/src/LuaManager.cpp +++ b/stepmania/src/LuaManager.cpp @@ -184,6 +184,8 @@ void LuaManager::ResetState() luaopen_string( L ); lua_settop(L, 0); // luaopen_* pushes stuff onto the stack that we don't need + RunScript( "nop = function(self) end" ); + for( const LuaFunctionList *p = g_LuaFunctions; p; p=p->next ) lua_register( L, p->name, p->func );