Jump to content
Sign in to follow this  
lozz08

Use a function/script to store a local variable?

Recommended Posts

I need to define a variable that is private, in one script, but then store it use it in another script without making a global variable. Is there a way to do this efficiently?

Share this post


Link to post
Share on other sites
I need to define a variable that is private, in one script, but then store it use it in another script without making a global variable. Is there a way to do this efficiently?

by using call or spawn you can have your script inside the other script and execute it seperatly using local variables without delay with spawn or wait for a return with call.

but local variables cannot be taken out of a script from the outside, but inside script locals can be transferred to outside scripts from the inside, if that made any sense for you.

Share this post


Link to post
Share on other sites

Your best bet is to use a gamelogic as a namespace, you can then copy / change it in and out to other scripts as often as you need. At the moment it's the (only??) way to easily share variables without making them global.

myGameLogic setVariable ["cars", 5];
_cars = myGameLogic getVariable "cars";

If only BIS would implement the :: scope resolution operator.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×