summaryrefslogtreecommitdiffstats
path: root/src/Bindings/LuaState.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-06-20 15:37:41 +0200
committerMattes D <github@xoft.cz>2015-06-20 15:37:41 +0200
commite06dd8f20ec3e6817e5638d5101cb8dc776846b4 (patch)
tree7400062806953c5fc1d8abd3ab9eaa74800d4872 /src/Bindings/LuaState.cpp
parentMerge pull request #2255 from cuberite/LoadablePieces (diff)
downloadcuberite-e06dd8f20ec3e6817e5638d5101cb8dc776846b4.tar
cuberite-e06dd8f20ec3e6817e5638d5101cb8dc776846b4.tar.gz
cuberite-e06dd8f20ec3e6817e5638d5101cb8dc776846b4.tar.bz2
cuberite-e06dd8f20ec3e6817e5638d5101cb8dc776846b4.tar.lz
cuberite-e06dd8f20ec3e6817e5638d5101cb8dc776846b4.tar.xz
cuberite-e06dd8f20ec3e6817e5638d5101cb8dc776846b4.tar.zst
cuberite-e06dd8f20ec3e6817e5638d5101cb8dc776846b4.zip
Diffstat (limited to 'src/Bindings/LuaState.cpp')
-rw-r--r--src/Bindings/LuaState.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index 9814d1c85..a0fdecb8b 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -835,8 +835,12 @@ bool cLuaState::GetStackValue(int a_StackPos, float & a_ReturnedVal)
cLuaState::cStackValue cLuaState::WalkToValue(const AString & a_Name)
{
- auto path = StringSplit(a_Name, ".");
+ // There needs to be at least one value on the stack:
+ ASSERT(lua_gettop(m_LuaState) > 0);
+
+ // Iterate over path and replace the top of the stack with the walked element
lua_pushvalue(m_LuaState, -1); // Copy the stack value into the "working area"
+ auto path = StringSplit(a_Name, ".");
for (const auto & elem: path)
{
// If the value is not a table, bail out (error):