Jump to content

Best way to share variables and functions beetween resources


Recommended Posts

Hello.

First, I tried putting all I needed into _G in all my different resources, thinking that I could use it to share stuff beetween them (_G.root = getRootElement(), etc..). It obviously didn't work. Then, I tried putting everything in one resource, using dofile() to load my scripts from subdirectories which got me an error message about it being an unsafe function.

So the question I'd like to ask is this: is there ANY way at all to share things beetween resources without using meta.xml? I don't want to write 350 lines of (and if I see it right on the wiki, it doesn't even work with variables) and a monolithic file is unmaintainable.

Any ideas?

Link to comment

You can't share variables, only functions using

call 

or exports.resource:exportedFunction(...) this is the only way, to allow calling from other resource you have to export it first in meta.

Here is more.

EDIT: you can try to make a function getVariables that will return _G table and export it.

Edited by Guest
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...