Jump to content

Environment and Global variables


Bonsai

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...