From e06dd8f20ec3e6817e5638d5101cb8dc776846b4 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 20 Jun 2015 15:37:41 +0200 Subject: Added basic support for loading village prefabs from files. --- src/Bindings/LuaState.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/Bindings') 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): -- cgit v1.2.3