godot_luaAPI
godot_luaAPI copied to clipboard
pull_variant is broken
(built from godot commit ae5668f)
pull_variant is always LuaError with error type 2 (generic runtime?)
here's my test code (sorry it's a little messy from me trying different things )
lua.push_variant(save.mission, 'MissionVariables')
for key in save.mission.Dict:
print(key)
lua.do_string("%s = MissionVariables.Dict.%s"%[key,key])
thread.load_string("print(Wow) Wow = 100 print(Wow) print(Bruh) function Wow() print(99999) end")
thread.resume()
await get_tree().create_timer(0.5).timeout
lua.do_string("function penis(num) print(num) return 200 end")
var penis = lua.pull_variant("penis")
# penis = penis as Callable IMPOSSIBLE BECAUSE IT'S AN OBJECT ??
print(penis)
# var num = penis.call()
# print(num)
for key in save.mission.Dict:
print(key)
print(lua.function_exists("Wow"))
var variant = lua.pull_variant("Wow")
print(variant)
print(typeof(variant))
save.mission.Dict[key] = variant
and the console output...
Wow
Bruh
50
100
69
[LuaError:-9223372008115403638]
Wow
true
[LuaError:-9223372008098626419]
21
Bruh
true
[LuaError:-9223372008081849191]
21
trying to save to a resource (my purpose here) nets this
[sub_resource type="Resource" id="Resource_5f7ft"]
script = SubResource("GDScript_v8376")
Dict = {
"Bruh": Object(LuaError,"type":2,"msg":"unkown lua type '8' in Lua::getVariant","script":null)
,
"Wow": Object(LuaError,"type":2,"msg":"unkown lua type '8' in Lua::getVariant","script":null)
}
if that helps. maybe something with godot broke it recently?
I still need to look into this more but here is what I know. The unkown lua type 8 is the type LUA_TTHREAD. Which means its trying to pull the thread its self from the stack. I think the issue is since these variable only exists on the thread and not on the lua state. We may have to add a pull variant method for thread specifically.
So the issue here as stated is lua threads have no push/pull variant methods of their own. We can kill 2 birds with one stone here. The main lua.cpp is absurdly huge. I think we extrapolate most of the lua specific code into a handler class. Then both lua and luaThread can use that.
Okay I came across some incorrect information before but I now know the issue. I have used incorrect indexing throughout the codebase as it is, I use a mix of relative and static indexing. using 1 instead -1. 1 gets the bottom of the lua_stack (I was under the impression it got the top). -1 will get the top of the stack which is equal to lua_gettop().
Should be resolved with 8bedbda38436848d7154ef20106c23635b4145bc