Home   Help Search Login Register  

Author Topic: createunit and array  (Read 502 times)

0 Members and 1 Guest are viewing this topic.

CopyrightPhilly

  • Guest
createunit and array
« on: 12 Jun 2005, 15:51:39 »
hey chaps,

ok i'm wanted to use the createunit command but then add the unit to an array so it can b later deleted.

i'm tryed:

Code: [Select]
_tmpunit = _type createunit [_pos,_group,"",1,"LIEUTENANT"]
unitarray = unitarray + _tmpunit

and also

Code: [Select]
_type createunit [_pos,_group,"_tmpunit = this",1,"LIEUTENANT"]
unitarray = unitarray + _tmpunit

but it just adds null to the array insted of the unit...

any ideas?

cheers, Phil

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:createunit and array
« Reply #1 on: 12 Jun 2005, 15:52:45 »
Try:

unitarray = unitarray + [_tmpunit]

CopyrightPhilly

  • Guest
Re:createunit and array
« Reply #2 on: 12 Jun 2005, 15:55:26 »
sorry my bad, it was already [_tmpunit] otherwise you just get an error about it expecting an array...

still, its just adding null to the array...

cheers, Philly

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:createunit and array
« Reply #3 on: 12 Jun 2005, 15:59:19 »
Okay, now try:

_type createunit [_pos,_group,"tmpunit = this",1,"LIEUTENANT"]
unitarray = unitarray + [tmpunit]

In otherwords make it a global name not a local name.

I presume that _type is defined and the unit is being created - you just cannot get its name.

CopyrightPhilly

  • Guest
Re:createunit and array
« Reply #4 on: 12 Jun 2005, 16:02:58 »
that worked

thanks for the help THobson

cheers,
Phil