Home   Help Search Login Register  

Author Topic: how do i use "foreach" in a trigger?  (Read 1496 times)

0 Members and 1 Guest are viewing this topic.

tai mai shu

  • Guest
how do i use "foreach" in a trigger?
« on: 02 Sep 2002, 07:01:47 »
hi.

i was wondering , how do i (without using scripts) use the "foreach thislist" command inside of the condition field of triggers???

for example:  how do i make a trigger go off when any person in a group (an array of units) is in a vehicle?  and then if this is true, single out THAT guy and pass it to a script (or make that person perform an action or command)?

so basically what im thinking is this:

condition :  ? ("_x in vehicle1" foreach group1)
activation : (guy who is in the vehicle) action ["eject"]

any help will be appreciated, as this is an important command for use in scripting and other stuff.

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:how do i use "foreach" in a trigger?
« Reply #1 on: 02 Sep 2002, 07:44:46 »
You can use "foreach" as a command, but not as a
condition.

In condition you need to use the count command.

"_x in vehicle1" count (units group1) == count (units group1)

: this condition expects all units of group1 to be inside vehicle1

"_x in vehicle1" count (units group1) > 0

: this condition expects at least one of the group to be inside

For your activation field, you might need a little trickier thingy.
You can pass the cargo of that vehicle into an array, and
execute the eject command foreach your_array.

invehiclearray=crew vehicle1 - driver vehicle1
followed by your eject action foreach invehiclearray

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

tai mai shu

  • Guest
Re:how do i use "foreach" in a trigger?
« Reply #2 on: 02 Sep 2002, 09:08:50 »
damn.  i wish i knew C++, that most likely explains how to handle arrays like this.   ???  :-\  >:(

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:how do i use "foreach" in a trigger?
« Reply #3 on: 02 Sep 2002, 09:18:05 »
Quote
d**n.  i wish i knew C++, that most likely explains how to handle arrays like this

 :D nope - that's generally the basics of any programmer's
language in combination with some mathematics

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

tai mai shu

  • Guest
Re:how do i use "foreach" in a trigger?
« Reply #4 on: 02 Sep 2002, 09:46:51 »
exactly.  it has a LOT to do with arrays and such.

tai mai shu

  • Guest
Re:how do i use "foreach" in a trigger?
« Reply #5 on: 02 Sep 2002, 21:23:05 »
erm, can anyone help?

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:how do i use "foreach" in a trigger?
« Reply #6 on: 02 Sep 2002, 22:07:19 »
If you have a vehicle named "vehcle1" and you want to eject everyone inside, the code would be as follows:

"_x action [""EJECT"", (vehicle _x)]" foreach crew vehicle1
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.