I manage to do what I wanted
MOBii_CreateTable("a", "b")
MOBii_AddIntToSubTable("a", "b", "c", 1)
Lua_Err = luaL_dostring(L, "print(~q### :: type(a.b.c):~q..type(a.b.c)..~q = ~q..a.b.c)")
Output: ### :: type(a.b.c):number = 1
' ---------------------------------------------------------[BLLua.MOBii_CallTableFunction]---
Function MOBii_AddIntToSubTable(_Table:String, _Sub:String, _key:String, _value:Int)
echo "ADD: " + _Table + "." + _Sub + "." + _key + " = " + _value
If L Then
If _Table And _Sub And _key Then
lua_pushstring(L, _Table) ' global _Table
lua_gettable(L, LUA_GLOBALSINDEX) ' Go in table
lua_getfield(L, -1, _Sub) ' Get the sub field table
lua_pushstring(L, _key) ' Set the key
lua_pushinteger(L, _value) ' push the value
lua_setfield(L, -3, _key)
lua_pop(L, 1) ' Do I need the lua_pop?
End If
End If
End Function
Do I need: lua_pop(L, 1), when do I need to use lua_pop?
|