have ActorCommands push themself
This commit is contained in:
@@ -677,8 +677,7 @@ void Actor::AddRotationR( float rot )
|
||||
|
||||
void Actor::RunCommands( const ActorCommands& cmds )
|
||||
{
|
||||
lua_pushstring(LUA->L, cmds.GetFunctionName()); // function name
|
||||
lua_gettable(LUA->L, LUA_GLOBALSINDEX); // function to be called
|
||||
cmds.PushSelf( LUA->L );
|
||||
this->PushSelf( LUA->L ); // 1st parameter
|
||||
lua_call(LUA->L, 1, 0); // call function with 1 argument and 0 results
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ ActorCommands::ActorCommands( const ActorCommands& cpy )
|
||||
* the function by reference, so we don't make a new function unless we're actually
|
||||
* changed. */
|
||||
ostringstream s;
|
||||
s << m_sLuaFunctionName << " = " << cpy.GetFunctionName();
|
||||
s << m_sLuaFunctionName << " = " << cpy.m_sLuaFunctionName;
|
||||
|
||||
CString s2 = s.str();
|
||||
LUA->RunScript( s2 );
|
||||
@@ -50,9 +50,12 @@ ActorCommands &ActorCommands::operator=( const ActorCommands& cpy )
|
||||
return *this;
|
||||
}
|
||||
|
||||
CString ActorCommands::GetFunctionName() const
|
||||
void ActorCommands::PushSelf( lua_State *L ) const
|
||||
{
|
||||
return m_sLuaFunctionName;
|
||||
lua_pushstring( L, m_sLuaFunctionName ); // function name
|
||||
lua_gettable( L, LUA_GLOBALSINDEX ); // function to be called
|
||||
|
||||
ASSERT_M( !lua_isnil(L, -1), m_sLuaFunctionName.c_str() )
|
||||
}
|
||||
|
||||
void ActorCommands::Register( const Commands& cmds )
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "RageUtil_AutoPtr.h"
|
||||
class Commands;
|
||||
|
||||
struct lua_State;
|
||||
|
||||
class ActorCommands
|
||||
{
|
||||
public:
|
||||
@@ -14,8 +16,7 @@ public:
|
||||
ActorCommands( const ActorCommands& cpy );
|
||||
ActorCommands &operator=( const ActorCommands& cpy );
|
||||
|
||||
|
||||
CString GetFunctionName() const;
|
||||
void PushSelf( lua_State *L ) const;
|
||||
|
||||
private:
|
||||
void Register( const Commands& cmds );
|
||||
|
||||
Reference in New Issue
Block a user