From 4cbf9be85ad334551934d6df755d47b93a26c227 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 5 Oct 2005 07:37:26 +0000 Subject: [PATCH] Add AddCommand and THEME:GetMetricA. This won't work with theme reloading, but that hasn't worked in a long time anyway (recreating the Lua environment while it's actually in use is hard). --- stepmania/src/Actor.cpp | 8 ++++++++ stepmania/src/ActorCommands.h | 2 +- stepmania/src/NoteSkinManager.cpp | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index 0c00590efb..578b67cca5 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -1394,6 +1394,13 @@ public: static int playcommand( T* p, lua_State *L ) { p->PlayCommand(SArg(1),NULL); return 0; } static int queuecommand( T* p, lua_State *L ) { p->QueueCommand(SArg(1)); return 0; } static int queuemessage( T* p, lua_State *L ) { p->QueueMessage(SArg(1)); return 0; } + static int addcommand( T* p, lua_State *L ) + { + LuaReference *pRef = new LuaReference; + pRef->SetFromStack( L ); + p->AddCommand( SArg(1), apActorCommands(pRef) ); + return 0; + } static int GetX( T* p, lua_State *L ) { lua_pushnumber( L, p->GetX() ); return 1; } static int GetY( T* p, lua_State *L ) { lua_pushnumber( L, p->GetY() ); return 1; } @@ -1524,6 +1531,7 @@ public: ADD_METHOD( playcommand ); ADD_METHOD( queuecommand ); ADD_METHOD( queuemessage ); + ADD_METHOD( addcommand ); ADD_METHOD( GetX ); ADD_METHOD( GetY ); diff --git a/stepmania/src/ActorCommands.h b/stepmania/src/ActorCommands.h index bc0cbddf7c..010e7710e0 100644 --- a/stepmania/src/ActorCommands.h +++ b/stepmania/src/ActorCommands.h @@ -18,7 +18,7 @@ private: CString m_sLuaFunction; }; -typedef AutoPtrCopyOnWrite apActorCommands; +typedef AutoPtrCopyOnWrite apActorCommands; #endif diff --git a/stepmania/src/NoteSkinManager.cpp b/stepmania/src/NoteSkinManager.cpp index 13ca37652f..7d5b17cc14 100644 --- a/stepmania/src/NoteSkinManager.cpp +++ b/stepmania/src/NoteSkinManager.cpp @@ -299,10 +299,12 @@ public: LunaNoteSkinManager() { LUA->Register( Register ); } static int GetPath( T* p, lua_State *L ) { lua_pushstring(L, p->GetPath(SArg(1),SArg(2)) ); return 1; } + static int GetMetricA( T* p, lua_State *L ) { p->GetMetricA(SArg(1),SArg(2))->PushSelf(L); return 1; } static void Register(lua_State *L) { ADD_METHOD( GetPath ); + ADD_METHOD( GetMetricA ); Luna::Register( L );