- Joined
- Apr 1, 2012
- Messages
- 1,249
- Solutions
- 71
- Reaction score
- 621
- Location
- Hell
- GitHub
- idontreallywolf
I have been trying to read a 2D lua-table in sources and I am not sure how to debug this.
The error msg that shows up is "attemp to index a boolean value".
What is going on here?
error msg on startup:
The error msg that shows up is "attemp to index a boolean value".
What is going on here?
Lua:
myLuaFunction({
{ a = 0, b = 123, c = "string", d = true, e = true, f = true },
{ a = 0, b = 123, c = "string", d = true, e = true, f = true }
})
C++:
int LuaScriptInterface::luaMyLuaFunction(lua_State* L)
{
if(!isTable(L, -1)) {
printf("not a table.");
return 1;
}
lua_pushnil(L);
while (lua_next(L, lua_gettop(L)) != 0) {
auto index = lua_gettop(L);
auto a = getField<int>(L, index, "a");
auto b = getField<int>(L, index, "b");
auto c = getFieldString(L, index, "c");
bool d = getField<bool>(L, index, "d");
bool e = getField<bool>(L, index, "e");
bool f = getField<bool>(L, index, "f");
lua_pop(L, 7);
}
lua_pop(L, 1);
return 1;
}
error msg on startup:
Code:
Lua Script Error: [Scripts Interface]
/Users/snavy/forgottenserver/data/scripts/test.lua
attempt to index a boolean value
stack traceback:
[C]: at 0x01093ec710
[C]: in function 'myLuaFunction'
...snavy/forgottenserver/data/scripts/test.lua:1: in main chunk
> test.lua [error]