Lua set table value to a.b.c = 1 from BlitzMax?

BlitzMax Forums/BlitzMax Programming/Lua set table value to a.b.c = 1 from BlitzMax?

MOBii(Posted 2016) [#1]
I make a Function that Create a sub table to a Global table
' ---------------------------------------------------------[BLLua.MOBii_CallTableFunction]---
Function MOBii_CreateTable(_Table:String, _Sub:String)
	If L Then
		If _Table Then
			lua_getglobal(L, _Table)
			If Not lua_istable(L, -1) Then
				lua_newtable(L) 										' Create table: _Table
				lua_setglobal(L, _Table)									' Main table
			End If
		Else
			Return
		End If
		If _Sub Then
			lua_pushstring(L, _Table)
			lua_gettable(L, LUA_GLOBALSINDEX)									' Get table _Table
			lua_newtable(L) 											' Create table
			lua_setfield(L, -2, _Sub)										' name table _Sub
		End If
	End If
End Function
If execute: MOBii_CreateTable("a", "b")
I can see that: type(a.b) == "table"

My problem is How can I add a value to a.b.c = 1 from BlitzMax?


MOBii(Posted 2016) [#2]
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?