Home   Help Search Login Register  

Author Topic: Foreach returns??  (Read 1986 times)

0 Members and 1 Guest are viewing this topic.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Foreach returns??
« Reply #15 on: 04 Sep 2005, 21:10:14 »
*Ahem*


Planck
I know a little about a lot, and a lot about a little.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Foreach returns??
« Reply #16 on: 04 Sep 2005, 21:12:38 »
lol ;D ;D ;D ;D

 :-X

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Foreach returns??
« Reply #17 on: 05 Sep 2005, 00:23:57 »
Wow this wasn't here this morning!

If you want the forEach command to create a list of unit positions try:

Code: [Select]
_positions = []
{_positions = _positions + [getPos _x]} forEach units group player
I haven't tested it but it looks like it should work

EDIT:
If you want an array of positions of all the unit in the player's group - but not the player (and I think you do want that if I remember your script correctly) then try:

Code: [Select]
_positions = []
{_positions = _positions + [getPos _x]} forEach ((units group player) - [player])


« Last Edit: 05 Sep 2005, 00:28:51 by THobson »

Offline paddy

  • Contributing Member
  • **
  • Llama whipping good
Re:Foreach returns??
« Reply #18 on: 05 Sep 2005, 10:16:01 »
Code: [Select]
_pos_array = []
{_pos_array = _pos_array + [(getpos _x)]} foreach _eastunits
hint format ["%1",_pos_array]


WAHH!!

I thought 'foreach' only worked with a string like in the comref, can this be true, can BIS comref be inaccurate again?

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Foreach returns??
« Reply #19 on: 05 Sep 2005, 10:29:54 »
ForEach works with any set of instructions.  These instructions are defined within a string.  Some people use "" to identify the string and some prefer {}

Offline paddy

  • Contributing Member
  • **
  • Llama whipping good
Re:Foreach returns??
« Reply #20 on: 05 Sep 2005, 10:34:16 »
That's news to me, well thanks guys.  This has definitly solved my dilemma.

However i'll leave the post open for another few days just incase someone else has questions or any brainwaves.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Foreach returns??
« Reply #21 on: 05 Sep 2005, 16:49:59 »
I just wanted to pop in and say that we did offer the same solution as THobson before all the editing went bananas, so it might have been missed because of that ;D

'My apologies for inconviniencing'... :P

Next time I will think before posting, I swear... ::)
« Last Edit: 05 Sep 2005, 16:50:43 by HateR_Kint »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Foreach returns??
« Reply #22 on: 05 Sep 2005, 17:12:27 »
I see it/them now. Replies#9 & 10.  

Last night I was in a hurry, I saw the question, skimmed some of the replies - saw some attempts to use format to get forEach to return a value, followed by lots of smileys so I stuck in my two cents worth.   Indeed you both had it right way back.

Next time I will think read before posting, I swear...

Possibly
 :)

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Foreach returns??
« Reply #23 on: 05 Sep 2005, 18:37:51 »
I'm not trying to have a pissin' contest here :P

Just saying that there actually was some logic in the smiley/edit chaos back there... somewhere... prolly...

:-X
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Foreach returns??
« Reply #24 on: 06 Sep 2005, 00:53:02 »
lol ;D :D :P

SMILIES

Offline paddy

  • Contributing Member
  • **
  • Llama whipping good
Re:Foreach returns??
« Reply #25 on: 07 Sep 2005, 12:47:30 »
Problem solved - Topic closed