Home   Help Search Login Register  

Author Topic: Group "MoveInCargo"?  (Read 2159 times)

0 Members and 1 Guest are viewing this topic.

Offline Mock360

  • Members
  • *
Group "MoveInCargo"?
« on: 13 Aug 2006, 05:10:46 »
Is there a command or script to "MoveInCargo" an entire named group? I have looked here, in other forums, and in a few scripting guides. Can't seem to find it.

Oh yeh - I'm a n00b at this scripting thing!

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: Group "MoveInCargo"?
« Reply #1 on: 13 Aug 2006, 07:01:38 »
Put this in the init field of one of the units of the group:

{_x moveInCargo vehiclename} forEach units group this

If you want to do the same thing in a script after the start of the mission put this line in your script

{_x moveInCargo vehiclename} forEach units nameofgroup

To give a group a name put this in the init field of one of the units in the group:

nameofgroup = group this
« Last Edit: 13 Aug 2006, 07:06:53 by THobson »

Offline Mock360

  • Members
  • *
Re: Group "MoveInCargo"?
« Reply #2 on: 13 Aug 2006, 12:45:27 »
Thank you for your response. It worked great.

Could you briefly explain or could you point me toward an explanation of the use of "{ }" brackets as opposed to "[ ]" brackets within the init line? When I inadvertantly used [_x moveInCargo vehiclename] instead of {_x moveInCargo vehiclename}, I got an error message that said I was trying to use a global variable in local environment.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re: Group "MoveInCargo"?
« Reply #3 on: 13 Aug 2006, 13:01:24 »
( )  [ ] and { } are profoundly different in OFP scripting.

( ) is used to make things happen in the right order.  For example (2+3)/4 is different from 2+(3/4)

[ ] is used to indicate taht the contents of the brackets constitute an array

{ } is used to indicate that the contents of the brackets is a string.   Sometimes you can use " " instead.

There are subtleties, which no doubt somebody will explain, but that's the basics of it. 
Plenty of reviewed ArmA missions for you to play

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: Group "MoveInCargo"?
« Reply #4 on: 13 Aug 2006, 14:15:00 »
I am with mac up to the  {} bit.

Think of "" as defining a string: "this is a string"
and {} as defining a block of code: {a=5;c=7;b=a+c}

They can sometimes be used interchangably - but sometimes not hence it is best to be clear on the distinction between a string and a block of code.

What I think was also implied by your question is how does the forEach command work.  It works like this:

{block of code using _x} forEach array

It will run the block of code once for every element of the array where each element replaces the _x.  So;

{_x setPos getPos player;[_x] join player} forEach [unit1,unit2,unit3]

will move each of the units to the location of the player and get them to join him.  It is exactly like:

unit1 setPos getPos player
[unit1] join player
unit2 setPos getPos player
[unit2] join player
unit3 setPos getPos player
[unit3] join player

Except it is neater and easier to read, and also less error prone.


« Last Edit: 13 Aug 2006, 14:17:42 by THobson »

Offline Mock360

  • Members
  • *
Re: Group "MoveInCargo"?
« Reply #5 on: 14 Aug 2006, 03:49:23 »
Thanks for the information. I think it is going to help with a VBIED (vehicle borne IED) script I have been experimenting with.