OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: ThEoNeAnDoNlY on 23 Apr 2005, 00:15:49

Title: setunitpos for whole squad
Post by: ThEoNeAnDoNlY on 23 Apr 2005, 00:15:49
hey, can someone please tell me how to make everyone in a squad follow the *this setunitpos "up"* command.

the only way i have found to do it is to write it in each persons individual init line which can be very tedious, so is there a way i can call it for the whole squad

Quote
e.g. "_x setunitpos "up"" foreach units group this

ofcourse i know that would not work but atleast you now know what im trying to achieve.

thanx

Guy
Title: Re:setunitpos for whole squad
Post by: Pilot on 23 Apr 2005, 00:19:30
Try this

{_x setunitpos "UP"} foreach units group this
Title: Re:setunitpos for whole squad
Post by: nigel on 23 Apr 2005, 05:14:53
Try this

{_x setunitpos "UP"} foreach units group this

I might be wrong... but I think the quotes have to be in a certain spot for that command.. i.e. "_x setunitpos {up}" foreach units group this

Title: Re:setunitpos for whole squad
Post by: Peter_Bullet on 23 Apr 2005, 06:26:48
Try this

{_x setunitpos "UP"} foreach units group this

I've used this many times and it has always worked.
Title: Re:setunitpos for whole squad
Post by: ThEoNeAnDoNlY on 23 Apr 2005, 18:53:36
ok thanx guys!

anyone wanna tell me exactly why it had to be laid outin such a way? im keen to learn!

Guy
Title: Re:setunitpos for whole squad
Post by: Peter_Bullet on 25 Apr 2005, 18:10:01
It is a command excecuted to every element in a given array where _x is the current element

like this {_x setDamage 1} forEach [s1,s2,s3,s4]
first time _x is s1 > it sets him dead, then s2 and then s3....
(you can also do like this) {_x setUnitPos "Up"; _x setDamage 1; _x something}

units group this: Units lists an array (list) of the men in a given group; group this returns the group where unit "this" is in....

I hope you understood, I'm not too good explaining these...  :-[
Title: Re:setunitpos for whole squad
Post by: ThEoNeAnDoNlY on 25 Apr 2005, 21:56:10
no no, that was a good explanation dont worry!

i understand now, i think it is important to know why these commands work and on posts such as this it is good to give explanations so that other people can learn.

thanx!

Guy
Title: Re:setunitpos for whole squad
Post by: Dubieman on 26 Apr 2005, 02:35:29
You sort of confused me there Epeli, but I got it. It just a command being applied to a whole group. Anyways, solve it if your done with it. ;)
Title: Re:setunitpos for whole squad
Post by: Sui on 27 Apr 2005, 07:57:25
I might be wrong... but I think the quotes have to be in a certain spot for that command.. i.e. "_x setunitpos {up}" foreach units group this

These are all valid lines that will work in that situation:

"_x setunitpos {up}" foreach units group this
{_x setunitpos "up"} foreach units group this
"_x setunitpos ""up""" foreach units group this

OFP differentiates between {}, "" and "" "".
Believe it or not you can string multiple nested quotes within one another using the right combination of quotes.

(Stop reading now if you don't want to be really confused)

I often use a trigger to activate a script command by passing it a string. the string ends up looking something like this:

string = """_x setbehaviour {aware}"" foreach [alpha, bravo, charlie]"

Which will work fine, provided you don't miscount the quotes ;)