don't bother parsing for empty commands
This commit is contained in:
@@ -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 = "";
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user