Home   Help Search Login Register  

Author Topic: format command problems  (Read 897 times)

0 Members and 2 Guests are viewing this topic.

Offline Tyger

  • Former Staff
  • ****
  • I was at OFPEC when it still had dirt floors...
    • OFPEC
format command problems
« on: 27 Jan 2006, 00:27:12 »
Code: [Select]
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:
Code: [Select]
call format[{"TYGAMMOBOX%1" |#|= _ammobox},TYGBOXCOUNT]
"People sleep soundly at night only because rough men stand ready to do violence on their behalf." - George Orwell

MSG Mike Everret - We Will Never Forget - '75-'08

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:format command problems
« Reply #1 on: 27 Jan 2006, 00:41:57 »



_ammobox = call format["TYGAMMOBOX%1" ,TYGBOXCOUNT]
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Tyger

  • Former Staff
  • ****
  • I was at OFPEC when it still had dirt floors...
    • OFPEC
Re:format command problems
« Reply #2 on: 27 Jan 2006, 00:54:55 »
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
"People sleep soundly at night only because rough men stand ready to do violence on their behalf." - George Orwell

MSG Mike Everret - We Will Never Forget - '75-'08

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:format command problems
« Reply #3 on: 27 Jan 2006, 01:00:03 »
call format [ {"TYGAMMOBOX%1"},TYGBOXCOUNT] = _ammobox

Just a guess.
Plenty of reviewed ArmA missions for you to play

Offline Tyger

  • Former Staff
  • ****
  • I was at OFPEC when it still had dirt floors...
    • OFPEC
Re:format command problems
« Reply #4 on: 27 Jan 2006, 01:21:38 »
Garr. It doesn't work. The bleeding game.  :P
"People sleep soundly at night only because rough men stand ready to do violence on their behalf." - George Orwell

MSG Mike Everret - We Will Never Forget - '75-'08

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:format command problems
« Reply #5 on: 27 Jan 2006, 01:45:59 »
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
« Last Edit: 27 Jan 2006, 01:46:53 by Triggerhappy »

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:format command problems
« Reply #6 on: 27 Jan 2006, 09:24:09 »
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).

Code: [Select]
TYGAMMOBOXES = TYGAMMOBOXES + [_ammobox]
The first ammo box is then (TYGAMMOBOXES select 0), the second one (TYGAMMOBOXES select 1), and so on.
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Tyger

  • Former Staff
  • ****
  • I was at OFPEC when it still had dirt floors...
    • OFPEC
Re:format command problems
« Reply #7 on: 27 Jan 2006, 19:09:26 »
Quote
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.
"People sleep soundly at night only because rough men stand ready to do violence on their behalf." - George Orwell

MSG Mike Everret - We Will Never Forget - '75-'08

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:format command problems
« Reply #8 on: 27 Jan 2006, 20:21:14 »
You've already solved the problem, but just for posterity, the correct way is this:

Code: [Select]
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?'
« Last Edit: 27 Jan 2006, 20:30:03 by Fragorl »