OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Kinnon on 18 Apr 2004, 15:44:07
-
lo all,
i'm not exactly new to OFP scripting but it has been a while, my problem is this :
I have one script that calls another with a single numeric variable being the only passed parameter :
_i = 0
_total = Count MyArray
#loop
...
[_i] exec "script.sqs" <----------- This is the bugger !
_i = _i + 1
?(_i < _total):goto "loop"
exit
So, it looks simple enough but for some reason my '_i' variable is being transmuted to a group, (West Alpha Black), !
But only when it calls the other script, if i keep track of it within the calling script it's value/type doesn't change.
Any input will be greatly appreciated.
thx
-
Have you tried changing _i to a global variable, I mean, use i instead of _i.
I think local variables are confined to the script they are created in.
Planck
-
Have you tried changing _i to a global variable, I mean, use i instead of _i.
I think local variables are confined to the script they are created in.
Planck
Nope. You can call other scripts using local variables of the "root" script. They're copied into the called script too. Then it's up to you - you can make the variable local also for the called script or make it global there.
Kinnon: Maybe you're getting the variable in the called script wrong. Are using this? :
_var = (_this select 0)
Because if you use only
_var = _this
it may cause some troubles.
If you're correct in this, post here the start of the called script. Maybe is something wrong there (?)
-
Thanks for that Jezuro, I'll make a note of that for future reference.
Scribbles hastily in his notepad
;D
Planck
-
Thanks, people, will try using 'this select 0' as was only using 'this'.