1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Function lua_mt_index(L:Byte Ptr) 	Local gObject:Object = lua_tolightobject(L, 1) 	Local gField:String = lua_tostring(L, 2) 	Print "Index: "+gField EndFunction Function lua_mt_newindex(L:Byte Ptr) 	Local gObject:Object = lua_tolightobject(L, 1) 	Local gField:String = lua_tostring(L, 2) 	Print "New Index: "+gField EndFunction Function lua_CreateThread(L:Byte Ptr) 	Local Code:String = luaL_checkstring(L, 1) 	If Len(Code) > 0 Then 		Local State:Byte Ptr = luaL_newstate() 		luaL_openlibs State 		lua_createtable State, 0, 0 		 		lua_pushcfunction State, lua_mt_index 		lua_setfield State, -2, "__index" 		 		lua_pushcfunction State, lua_mt_newindex 		lua_setfield State, -2, "__newindex" 		 		lua_getglobal State, "_G" 		lua_setmetatable State, -2 		luaL_dostring State, Code 		 		Print "Error: "+lua_tostring(State, -1) 		 		'Local Script:TLuaThreadScript = New TLuaThreadScript.Create(State, Code) 	EndIf EndFunction
Does anyone know how to set a metatable to _G using the C functions?
Note: I know this one is not working on different threads yet but I need to make it load the script and run the functions first.