diff options
author | peterbell10 <peterbell10@live.co.uk> | 2017-08-18 12:29:54 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2017-08-18 12:29:54 +0200 |
commit | b8dda388e0cf300f573d411dc670099e56c2e3c3 (patch) | |
tree | 6c3f40beb7a652f9c5afa560954e68a53db54401 /src/Bindings/LuaState.cpp | |
parent | Changed type of FastRandom in monster drop calculation. (#3920) (diff) | |
download | cuberite-b8dda388e0cf300f573d411dc670099e56c2e3c3.tar cuberite-b8dda388e0cf300f573d411dc670099e56c2e3c3.tar.gz cuberite-b8dda388e0cf300f573d411dc670099e56c2e3c3.tar.bz2 cuberite-b8dda388e0cf300f573d411dc670099e56c2e3c3.tar.lz cuberite-b8dda388e0cf300f573d411dc670099e56c2e3c3.tar.xz cuberite-b8dda388e0cf300f573d411dc670099e56c2e3c3.tar.zst cuberite-b8dda388e0cf300f573d411dc670099e56c2e3c3.zip |
Diffstat (limited to 'src/Bindings/LuaState.cpp')
-rw-r--r-- | src/Bindings/LuaState.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index 07a91f49e..185759acc 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -1151,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); |