Bonsai Posted September 5, 2016 Share Posted September 5, 2016 Hey, I have a problem with loading script files of maps into an environment. If a map uses "addEventHandler" to e.g. add the event "onClientMarkerHit" it most likely uses the "source" variable inside the attached function. However, this source variable does not exist in the scripts environment. The only way to still make it work at the moment is to let it have access to the _G environment, where the variable seems to exist. Is there a way to make it work without that? Bonsai Link to comment
Bonsai Posted September 5, 2016 Author Share Posted September 5, 2016 Sorry for double post, I can't edit my original post somehow. I meanwhile tried something, which seem to work, but I would appreciate if anyone can confirm that to be a solid solution for the problem. Basically, I modify the metatable of _G and redirect all changes there into my newly created environment. Link to comment
Audifire Posted September 5, 2016 Share Posted September 5, 2016 (edited) Maybe you can create a environment metatable with __index = _G Here a little example: https://github.com/multitheftauto/mtasa-resources/blob/master/[editor]/edf/scriptreader_client.lua It seems to be more secure for me. Edited September 5, 2016 by Audifire Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now