WeaselGames / godot_luaAPI

Godot LuaAPI
https://luaapi.weaselgames.info
Other
391 stars 30 forks source link

can't resume a sub-environment #43

Closed BestestHD closed 1 year ago

BestestHD commented 2 years ago

to preface, sorry about all the issues 😅 i'm trying to put together a game extensively using lua but these issues are very problematic (except the pull_variant one which i've learned to work around fortunately) this one's pretty self-explanatory, if I load a string into a thread reading

_ENV = game
print(9000)
wait_timer(2.0)
print(2000)

it never prints 2000, only 9000 (i've tried a myriad of different ways, including just calling yield, waiting in gdscript, then resuming the thread. nothing) all relevant functions are exposed to the table/environment of course.

evidently, execution does stop, so i think it's an issue with LuaThread.resume? i'd guess it's only resuming execution of the global environment. i think that some method of assigning a thread an environment from GDScript would be ideal and circumvent this issue, but there's probably some better way... idk (there's also no equivalent of push_variant/pull_variant for a sub-environment but that's not a big deal just requires a bit of extra code haha)

Trey2k commented 1 year ago

The issue here is that lua threads do not have a _ENV variable I think. https://stackoverflow.com/questions/57030514/changing-the-env-of-a-lua-thread-using-c-api

Trey2k commented 1 year ago

If you think this is not the case let me know