diff options
author | madmaxoft <github@xoft.cz> | 2013-08-09 14:58:43 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2013-08-09 14:58:43 +0200 |
commit | d4a3c451c43454176af39aad5cede5281615a6ad (patch) | |
tree | a3dc0500db414ed3b03ca5b983353400dcae4bcd /source/LuaState.cpp | |
parent | Merge pull request #52 from ravenscroftj/feature/food (diff) | |
download | cuberite-d4a3c451c43454176af39aad5cede5281615a6ad.tar cuberite-d4a3c451c43454176af39aad5cede5281615a6ad.tar.gz cuberite-d4a3c451c43454176af39aad5cede5281615a6ad.tar.bz2 cuberite-d4a3c451c43454176af39aad5cede5281615a6ad.tar.lz cuberite-d4a3c451c43454176af39aad5cede5281615a6ad.tar.xz cuberite-d4a3c451c43454176af39aad5cede5281615a6ad.tar.zst cuberite-d4a3c451c43454176af39aad5cede5281615a6ad.zip |
Diffstat (limited to '')
-rw-r--r-- | source/LuaState.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/source/LuaState.cpp b/source/LuaState.cpp index 367a04266..7462181ad 100644 --- a/source/LuaState.cpp +++ b/source/LuaState.cpp @@ -625,6 +625,58 @@ void cLuaState::Push(const HTTPTemplateRequest * a_Request) +void cLuaState::Push(cTNTEntity * a_TNTEntity) +{ + ASSERT(IsValid()); + ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first + + tolua_pushusertype(m_LuaState, a_TNTEntity, "cTNTEntity"); + m_NumCurrentFunctionArgs += 1; +} + + + + + +void cLuaState::Push(cCreeper * a_Creeper) +{ + ASSERT(IsValid()); + ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first + + tolua_pushusertype(m_LuaState, a_Creeper, "cCreeper"); + m_NumCurrentFunctionArgs += 1; +} + + + + + +void cLuaState::Push(Vector3i * a_Vector) +{ + ASSERT(IsValid()); + ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first + + tolua_pushusertype(m_LuaState, a_Vector, "Vector3i"); + m_NumCurrentFunctionArgs += 1; +} + + + + + +void cLuaState::Push(void * a_Ptr) +{ + ASSERT(IsValid()); + ASSERT(m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first + + lua_pushnil(m_LuaState); + m_NumCurrentFunctionArgs += 1; +} + + + + + void cLuaState::GetReturn(int a_StackPos, bool & a_ReturnedVal) { a_ReturnedVal = (tolua_toboolean(m_LuaState, a_StackPos, a_ReturnedVal ? 1 : 0) > 0); @@ -658,6 +710,18 @@ void cLuaState::GetReturn(int a_StackPos, int & a_ReturnedVal) +void cLuaState::GetReturn(int a_StackPos, double & a_ReturnedVal) +{ + if (lua_isnumber(m_LuaState, a_StackPos)) + { + a_ReturnedVal = tolua_tonumber(m_LuaState, a_StackPos, a_ReturnedVal); + } +} + + + + + bool cLuaState::CallFunction(int a_NumResults) { ASSERT (m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first |