• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

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?
 
Level 8
Joined
Nov 9, 2008
Messages
502
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.
 
Level 8
Joined
Aug 1, 2008
Messages
420
Ok, thats just too confusing. I think ill just stick with removing them normally. Thanks anyway, +rep to both..
 
Level 8
Joined
Nov 9, 2008
Messages
502
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.
 
Level 8
Joined
Nov 9, 2008
Messages
502
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.
 
Level 8
Joined
Aug 1, 2008
Messages
420
It would be easier just doing it normally if you only have 3-4 arrays though. Theres more actions doing it your ways xD
 
Level 8
Joined
Nov 9, 2008
Messages
502
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
 
Level 13
Joined
Mar 4, 2009
Messages
1,156
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...
 
Level 8
Joined
Aug 1, 2008
Messages
420
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
 
Level 8
Joined
Aug 1, 2008
Messages
420
Oh, ok pharoah, ill try that in a second. I just edited my post above, can you take a quick look at that aswell?
 
Level 8
Joined
Aug 1, 2008
Messages
420
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.
Top