Home   Help Search Login Register  

Author Topic: array problem  (Read 803 times)

0 Members and 2 Guests are viewing this topic.

Offline Blanco

  • Former Staff
  • ****
array problem
« on: 24 Apr 2005, 01:17:59 »

;placement_beta

Code: [Select]
randompos = [[[8712.51,1633.06,0],193.092],[[8695.72,1632.16,3.24218],175.425],[[8690.19,1631.55,3.09848],172.283],[[8676.48,1631.92,2.78604],183.858],[[8676.24,1635.88,2.87307],229.63],[[8686.87,1615.96,0],170.67],[[8675.81,1589.19,0],145.448],[[8690.56,1626.23,0],170.092]]
tangos = [a1,a2,a3,a4,a5,a6,a7,a8]

_ct = count tangos
_cp = count randompos

?_ct < _cp : hint "#error";exit

_i = 0
#loop
_r = random count tangos
_r = _r - _r %1
_unit = tangos select _r

tangos = tangos - [_unit]

_p = random count randompos
_p = _p - _p %1
_arr = randompos select _p

randompos = randompos - [_arr] <=== I think the problem is here

_rpos = (_arr select 0)
_dir = (_arr select 1)
_unit setpos _rpos
_unit setdir _dir
_i = _i + 1
~2

hint format ["%1\n%2",_i,count randompos]
?_i < _ct : goto "loop"

Each element in the randompos array contains a position array and a direction.
I put every unit from the tangos array in a randomly chosen position and each loop I update the randompos array by substracting the element.
But it doesn't happen... the array stays the same...
Some units are setposed on the same spot.

What am I doing wrong?  
Search or search or search before you ask.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:array problem
« Reply #1 on: 24 Apr 2005, 01:35:54 »
The - command does not work if the array elements are themselves arrays.     As you have just discovered.   ;D

Regret I don't know the workaround, assuming there is one.
Plenty of reviewed ArmA missions for you to play

Offline ACF

  • Members
  • *
  • Llama?? Ain't that French for tanks?
Re:array problem
« Reply #2 on: 24 Apr 2005, 01:40:09 »
It's late so it's more of a workaround than a solution (that's if it works!):

Instead of:
Code: [Select]
_arr = randompos select _p
randompos = randompos - [_arr]

You could try:
Code: [Select]
_arr = randompos select _p
randompos Set [_p,"deleteme"]
randompos = randompos - ["deleteme"]

Any joy?

Ooh that was spooky...
« Last Edit: 24 Apr 2005, 01:40:57 by ACF »

Offline Blanco

  • Former Staff
  • ****
Re:array problem
« Reply #3 on: 24 Apr 2005, 01:43:20 »
ACF, that worked perfect!  :cheers:
Thanks a lot. (again)


Search or search or search before you ask.