summaryrefslogtreecommitdiffstats
path: root/src/Bindings/LuaState.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Bindings/LuaState.cpp')
-rw-r--r--src/Bindings/LuaState.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index e30d0ed5f..185759acc 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -875,6 +875,17 @@ void cLuaState::Push(const char * a_Value)
+void cLuaState::Push(const cItem & a_Item)
+{
+ ASSERT(IsValid());
+ auto c = new cItem(a_Item);
+ tolua_pushusertype_and_takeownership(m_LuaState, c, "cItem");
+}
+
+
+
+
+
void cLuaState::Push(const cNil & a_Nil)
{
ASSERT(IsValid());
@@ -1140,6 +1151,37 @@ bool cLuaState::GetStackValue(int a_StackPos, AStringMap & a_Value)
+bool cLuaState::GetStackValue(int a_StackPos, AStringVector & a_Value)
+{
+ // Retrieve all values in an array of string table:
+ if (!lua_istable(m_LuaState, a_StackPos))
+ {
+ return false;
+ }
+ cStackTable tbl(*this, a_StackPos);
+ bool isValid = true;
+ tbl.ForEachArrayElement([&](cLuaState & a_LuaState, int a_Index)
+ {
+ AString tempStr;
+ if (a_LuaState.GetStackValue(-1, tempStr))
+ {
+ a_Value.push_back(std::move(tempStr));
+ }
+ else
+ {
+ isValid = false;
+ return true;
+ }
+ return false;
+ }
+ );
+ return isValid;
+}
+
+
+
+
+
bool cLuaState::GetStackValue(int a_StackPos, bool & a_ReturnedVal)
{
a_ReturnedVal = (tolua_toboolean(m_LuaState, a_StackPos, a_ReturnedVal ? 1 : 0) > 0);