diff options
author | madmaxoft <github@xoft.cz> | 2013-07-29 10:03:42 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2013-07-29 10:03:42 +0200 |
commit | e51221eaf9310f862bf65c9b311ac7c6b7537c18 (patch) | |
tree | 5e0e52da567c37a925d90f72cfa5356d9f55a783 | |
parent | Merge pull request #14 from mc-server/hunger (diff) | |
download | cuberite-e51221eaf9310f862bf65c9b311ac7c6b7537c18.tar cuberite-e51221eaf9310f862bf65c9b311ac7c6b7537c18.tar.gz cuberite-e51221eaf9310f862bf65c9b311ac7c6b7537c18.tar.bz2 cuberite-e51221eaf9310f862bf65c9b311ac7c6b7537c18.tar.lz cuberite-e51221eaf9310f862bf65c9b311ac7c6b7537c18.tar.xz cuberite-e51221eaf9310f862bf65c9b311ac7c6b7537c18.tar.zst cuberite-e51221eaf9310f862bf65c9b311ac7c6b7537c18.zip |
-rw-r--r-- | source/LuaScript.cpp | 16 | ||||
-rw-r--r-- | source/LuaScript.h | 27 |
2 files changed, 40 insertions, 3 deletions
diff --git a/source/LuaScript.cpp b/source/LuaScript.cpp index b55ff3520..8d92c238f 100644 --- a/source/LuaScript.cpp +++ b/source/LuaScript.cpp @@ -1,4 +1,8 @@ +// LuaScript.cpp + +// Implements the cLuaScript class that loads a Lua script file to produce a web template out of it + #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "LuaScript.h" @@ -186,10 +190,14 @@ bool cLuaScript::CallFunction( const char* a_Function, AString& ReturnedString ) // Push the desired function on the stack if (!LuaPushFunction(a_Function)) + { return false; + } if (!LuaCallFunction(0, 1, a_Function)) + { return false; + } if (lua_isstring(m_LuaState, -1)) { @@ -211,12 +219,16 @@ bool cLuaScript::CallFunction( const char* a_Function, const sLuaUsertype& a_Use // Push the desired function on the stack if (!LuaPushFunction(a_Function)) + { return false; + } tolua_pushusertype(m_LuaState, a_UserType.Object, a_UserType.ClassName); if (!LuaCallFunction(1, 1, a_Function)) + { return false; + } if (lua_isstring(m_LuaState, -1)) { @@ -238,13 +250,17 @@ bool cLuaScript::CallFunction( const char* a_Function, const sLuaUsertype& a_Use // Push the desired function on the stack if (!LuaPushFunction(a_Function)) + { return false; + } tolua_pushusertype(m_LuaState, a_UserType1.Object, a_UserType1.ClassName); tolua_pushusertype(m_LuaState, a_UserType2.Object, a_UserType2.ClassName); if (!LuaCallFunction(2, 1, a_Function)) + { return false; + } if (lua_isstring(m_LuaState, -1)) { diff --git a/source/LuaScript.h b/source/LuaScript.h index cf4806903..f98b2e65b 100644 --- a/source/LuaScript.h +++ b/source/LuaScript.h @@ -1,14 +1,31 @@ + +// LuaScript.h + +// Declares the cLuaScript class that loads a Lua script file to produce a web template out of it + + + + + #pragma once struct lua_State; + + + + struct sLuaUsertype { sLuaUsertype(void* a_pObject, const char* a_pClassName) : Object(a_pObject), ClassName(a_pClassName) {} // void* Object; - const char* ClassName; -}; + const char* ClassName; +} ; + + + + class cLuaScript { @@ -39,4 +56,8 @@ protected: bool LuaCallFunction(int a_NumArgs, int a_NumResults, const char * a_FunctionName ); // a_FunctionName is only used for error messages, nothing else private: lua_State* m_LuaState; -};
\ No newline at end of file +} ; + + + + |