OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Tyger on 27 Jan 2006, 00:27:12
-
call format[{"TYGAMMOBOX%1" = _ammobox},TYGBOXCOUNT]
Simply, why is that bit 'o code not working? TYGBOXCOUNT is predefined as 0 in the init.sqs, and _ammobox is a "ReammoBoxWest" created earlier in the script. I am trying to make a dynamic way for the user to spawn multiple ammo boxes, and give them each a global name so that they don't have to edit the script to add weapons and ammo to them.
The error that code produces is:
call format[{"TYGAMMOBOX%1" |#|= _ammobox},TYGBOXCOUNT]
-
_ammobox = call format["TYGAMMOBOX%1" ,TYGBOXCOUNT]
-
Ay, but the problem with that is that _ammobox is the local variable of the ammobox. I am trying to store that local variable into a global variable. Yours would set teh local variable as the global, which as of yet ceases to have any value. :P
Sodding game ;D
-
call format [ {"TYGAMMOBOX%1"},TYGBOXCOUNT] = _ammobox
Just a guess.
-
Garr. It doesn't work. The bleeding game. :P
-
take out the quotes, you're setting a string equal to _ammobox, which is a no no ;D
and then use your original code mac's won't work, nor will terox's
-
Pardon my ignorance, but why are you bothering with all this format nonsense?
Why not just use a single array-type variable? ??? ??? ???
I would think that would be easier to deal with scripting-wise, and it would also save on global variables (too many of which can corrupt saved games).
TYGAMMOBOXES = TYGAMMOBOXES + [_ammobox]
The first ammo box is then (TYGAMMOBOXES select 0), the second one (TYGAMMOBOXES select 1), and so on.
-
take out the quotes, you're setting a string equal to _ammobox, which is a no no
I was going for a global variable :P
@GB
Ah. Brilliant. :D That will help a bunch.
-
You've already solved the problem, but just for posterity, the correct way is this:
call format[{TYGAMMOBOX%1 = _ammobox},TYGBOXCOUNT]
No extra quotes #EDIT as Triggerhappy pointed out.
Remember, the call command executes the contents of its string as though you had written that down, in your script, yourself. Sometimes it helps to hint out the string, read it in game and think to yourself 'If I wrote that exact code down in a script, would it work?'