• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[Trigger] Variables using array

Status
Not open for further replies.
Level 9
Joined
Jun 26, 2005
Messages
511
how do i make a variables that keeps making array for it self?
for ex.

do integer 1-50
-create dummy unit for player 1
-set temp unit[0 + 1] = last created unit

now the thing is i want the variable to do +1 +2 +3, so it would store all created units but i cant seem to get it to work.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Well, you can declare a Ineger and raise its value by 1 each time you create a unit, like this

  • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
  • Set Unit[Integer] = (Last created unit)
  • Set Integer = (Integer + 1)

However, in my opinion, the best way to do this is using a loop like this (in case you are creating them one after another)

  • For each (Integer A) from 1 to 50, do (Actions)
    • Loop - Actions
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Set Unit[(Integer A)] = (Last created unit)

When the loop runs its "1" (first time it runs), it will set your unit to Unit[1], when it runs its "2" it will set it to Unit[2] and so on untill 50.

 
Level 19
Joined
Aug 24, 2007
Messages
2,888
Tip: Put a Custom script: call DestroyGroup(bj_lastCreatedGroup)

CreateNUnitsAtLoc (Unit - Create ...) Creates an Unit Group and its bj_lastCreatedGroup
(bj_wantDestroyGroup doesnt work because it doesnt check that variable nor contains anything to destroy that group)
 
Status
Not open for further replies.
Top