OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Kinnon on 18 Apr 2004, 15:44:07

Title: Seems simple, but i can't figure it, please help ...
Post 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



Title: Re:Seems simple, but i can't figure it, please help ...
Post by: Planck on 18 Apr 2004, 16:40:34
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
Title: Re:Seems simple, but i can't figure it, please help ...
Post by: Jezuro on 18 Apr 2004, 20:19:01
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 (?)
Title: Re:Seems simple, but i can't figure it, please help ...
Post by: Planck on 18 Apr 2004, 20:30:06
Thanks for that Jezuro, I'll make a note of that for future reference.

Scribbles hastily in his notepad

 ;D


Planck
Title: Re:Seems simple, but i can't figure it, please help ...
Post by: Kinnon on 24 Apr 2004, 19:33:15
Thanks, people, will try using 'this select 0' as was only using 'this'.