summaryrefslogtreecommitdiffstats
path: root/src/Bindings/LuaState.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-03-04 21:55:24 +0100
committermadmaxoft <github@xoft.cz>2014-03-04 21:55:24 +0100
commitecfe17b096994649610c03561496d8506648322c (patch)
treeb8e03ee7bbd93d6a2149114a1a62f508aa2b32eb /src/Bindings/LuaState.cpp
parentFixed an assert in map-loading. (diff)
downloadcuberite-ecfe17b096994649610c03561496d8506648322c.tar
cuberite-ecfe17b096994649610c03561496d8506648322c.tar.gz
cuberite-ecfe17b096994649610c03561496d8506648322c.tar.bz2
cuberite-ecfe17b096994649610c03561496d8506648322c.tar.lz
cuberite-ecfe17b096994649610c03561496d8506648322c.tar.xz
cuberite-ecfe17b096994649610c03561496d8506648322c.tar.zst
cuberite-ecfe17b096994649610c03561496d8506648322c.zip
Diffstat (limited to '')
-rw-r--r--src/Bindings/LuaState.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index a5540df17..1890dcfe5 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -716,7 +716,7 @@ void cLuaState::Push(cBlockEntity * a_BlockEntity)
-void cLuaState::GetReturn(int a_StackPos, bool & a_ReturnedVal)
+void cLuaState::GetStackValue(int a_StackPos, bool & a_ReturnedVal)
{
a_ReturnedVal = (tolua_toboolean(m_LuaState, a_StackPos, a_ReturnedVal ? 1 : 0) > 0);
}
@@ -725,11 +725,17 @@ void cLuaState::GetReturn(int a_StackPos, bool & a_ReturnedVal)
-void cLuaState::GetReturn(int a_StackPos, AString & a_ReturnedVal)
+void cLuaState::GetStackValue(int a_StackPos, AString & a_Value)
{
- if (lua_isstring(m_LuaState, a_StackPos))
+ size_t len = 0;
+ const char * data = lua_tolstring(m_LuaState, a_StackPos, &len);
+ if (data != NULL)
+ {
+ a_Value.assign(data, len);
+ }
+ else
{
- a_ReturnedVal = tolua_tocppstring(m_LuaState, a_StackPos, a_ReturnedVal.c_str());
+ a_Value.clear();
}
}
@@ -737,7 +743,7 @@ void cLuaState::GetReturn(int a_StackPos, AString & a_ReturnedVal)
-void cLuaState::GetReturn(int a_StackPos, int & a_ReturnedVal)
+void cLuaState::GetStackValue(int a_StackPos, int & a_ReturnedVal)
{
if (lua_isnumber(m_LuaState, a_StackPos))
{
@@ -749,7 +755,7 @@ void cLuaState::GetReturn(int a_StackPos, int & a_ReturnedVal)
-void cLuaState::GetReturn(int a_StackPos, double & a_ReturnedVal)
+void cLuaState::GetStackValue(int a_StackPos, double & a_ReturnedVal)
{
if (lua_isnumber(m_LuaState, a_StackPos))
{