-
-
Notifications
You must be signed in to change notification settings - Fork 803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scripting: Some issues building with Lua 5.1 #2967
Comments
Bumping this up because I'm super interested in the problem as well as the script op is building that greatly improves accessibility for a game series I play a lot, and the issue seems to have been berried. |
I've edited first comment. For some reason, part of the code became broken. By the way, now I'm almost sure the error is related to how Lua 5.1 handles environments, metatables and all of that. I think that in some momment the engine creates some table which is OK for Lua 5.2+ structure, but not for Lua 5.1, and Lua 5.1 finds a table when its looking for a function. The problem is I cannot find where I can start in order to fix that. |
PR #3376 would fix this. |
Please don't close it until after the PR is merged |
I'm finding some issues trying to use mGBA with Lua 5.1.
What I've found and what I've fixed:
script/engines/lua.c:
line 224:
In order to fix this, I tried to do:
Original code:
script/engines/lua.c:
...
My solution:
As lua_getupvalue is getting the _ENV upvalue which lua_load creates when loading a script on Lua 5.2+, for Lua 5.1 I replaced those two lua_getupvalue calls with getfenv calls, which get the _G variable of the loaded script, which should be equivalent to the _ENV variable from Lua 5.2+:
This fixed the crash, but now I'm finding another error when loading any script: [ERROR] attempt to call a table value.
I think this is related to environments too (something with Lua 5.1 creating an environment for each function it declares or something like that, but I'm a bit lost here.
Any idea?
The text was updated successfully, but these errors were encountered: