• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

Group Help

Status
Not open for further replies.
Level 2
Joined
Jan 17, 2019
Messages
15
please help me fix the error. I do not understand what is wrong.
I have a function that takes data. (function grouping takes integer i returns nothing) But I don’t know how to transfer it there correctly
upload_2019-11-20_7-21-47.png
 
ForGroup runs in a separate function so the only way to access that data is to assign it to a global variable that you then reference in the function that’s used in the ForGroup. This is a perfectly acceptable way to do it as with proper practice there is no chance for the variable to be overwritten. Even if you don’t understand vJASS additions you can take advantage of the free declare globals blocks:
JASS:
globals
  integer MyIntName = 0
endglobals
The other solution is to build your own group loop within the function. This has a side effect of removing all the units from the group when you loop through it so it’s probably not great if you want to retain the group (though you can just add them to another empty group instead).
JASS:
local unit u
loop
  set u = FirstOfGroup(g)
  exitwhen u == null
  call GroupRemoveUnit(g, u)
  //do stuff with u here
endloop
 
Status
Not open for further replies.
Back
Top