• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Can you remove an array without doing multiple functions?

Status
Not open for further replies.
Level 8
Joined
Aug 1, 2008
Messages
420
Say if i had something like this... (example)

  • Set TempGroup[1] = (Units owned by (Player 1 (Red)
  • Set TempGroup[2] = (Units owned by (Player 2 (Blue)
  • Set TempGroup[3] = (Units owned by (Player 3 (Teal)
Do i have to do
  • Custom script: call DestroyGroup(TempGroup[1])
  • Custom script: call DestroyGroup(TempGroup[2])
  • Custom script: call DestroyGroup(TempGroup[3])
Or can i just do one function, that removes them all, to shorten it?
 
You need an integer, let's call it x for now.

  • set x = 0
  • Custom Script: loop
  • Custom Script: exitwhen x == 4 //thats the max number of times you want it to loop +1
  • Custom Script: call DestroyGroup(TempGroup[x])
  • set x = x + 1
  • Custom Script: endloop
I believe that will work.
 
Ok, thats just too confusing. I think ill just stick with removing them normally. Thanks anyway, +rep to both..
 
Lol that's basicly the same except you suddenly used x instead of i xDDDDD

Anyway, don't let the Jass confuse you. Just copy it into some custom scripts and it works for you.
 
Let me rephrase it for you.

  • Actions
    • Set x = 0
    • Custom script: loop
    • Custom script: exitwhen x < 3
    • Custom script: call DestroyForce[x]
    • Set x = (x + 1)
    • Custom script: endloop
Integer x can be reused as long as it is instant.
 
It would be easier just doing it normally if you only have 3-4 arrays though. Theres more actions doing it your ways xD
 
I did it with real Jass instead of Custom Scripts. Everyone should learn Jass anyways, it isn't hard at all.

Who is to say whether something is hard for one or the other?

Anyway you forgot to edit another x in your post xDDDDDDDDDD
 
Say if i had something like this... (example)

  • Set TempGroup[1] = (Units owned by (Player 1 (Red)
  • Set TempGroup[2] = (Units owned by (Player 2 (Blue)
  • Set TempGroup[3] = (Units owned by (Player 3 (Teal)
Do i have to do
  • Custom script: call DestroyGroup(TempGroup[1])
  • Custom script: call DestroyGroup(TempGroup[2])
  • Custom script: call DestroyGroup(TempGroup[3])
Or can i just do one function, that removes them all, to shorten it?

maybe

for each integer from 1 to 4 do actions
Custom script: call DestroyGroup(TempGroup[integer A])

oh,hvo-busterkomo already said it...
 
Sadly you cant do Call DestroyGroup(Tempgroup[integer A]), comes up with an error :(

i50rop.jpg


Let me rephrase it for you.

  • Actions
    • Set x = 0
    • Custom script: loop
    • Custom script: exitwhen x < 3
    • Custom script: call DestroyForce[x]
    • Set x = (x + 1)
    • Custom script: endloop
Integer x can be reused as long as it is instant.
+ I tried that and it gives a syntax error at "call DestroyForce[x]" I even tried "call DestroyGroup[x]". It still didnt work.

Edit: I think its working. But i still got this error for some reason. Says "Undeclared Variable x" when i did declare it! Heres the picture.

2qc14pj.jpg
 
Oh, ok pharoah, ill try that in a second. I just edited my post above, can you take a quick look at that aswell?
 
Thought so, i done that already. Ill try the > now.
It still says undeclared variable! Even though i did declare it. whats going on?
Edit: I now did
  • Custom script: local integer x = 0
And its working now, thx everybody.
 
Status
Not open for further replies.
Back
Top