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!
private function test takes nothing returns nothing
local unit u
local group g = CreateGroup()
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null)
for u in g
call KillUnit(u)
endfor
call DestroyGroup(g)
set g = null
endfunction
On the website for is in bold, but endfor is not. And in my JassHelper nothing is bold when using for loops.
private function test takes nothing returns nothing
local unit u
local group g = CreateGroup()
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null)
for u in g
call KillUnit(u)
endfor
call DestroyGroup(g)
set g = null
endfunction
On the website for is in bold, but endfor is not. And in my JassHelper nothing is bold when using for loops.
Eerm are you 100% positive for loops can be used in vJass without using ZINC? Where did you read this?
The only refference I found was this: http://www.wc3c.net/vexorian/zincmanual.html "Factorial"
Isn't using normal loops a better solution?
Also u is undefined. You can not kill a unit that does not exist, nor check if a non-existing unit is within a unit group.
Perhaps something like this is what you are searching for?
JASS:
private function test takes nothing returns nothing
local unit u
local group g = CreateGroup()
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
//do something here
call GroupRemoveUnit(u)
endloop
call DestroyGroup(g)
set g = null
endfunction
Here I set u to be the first unit picked from the group, then do some actions with that unit,
then remove the unit from the group and so on untill there are no units in the group. Thus u = null.
As far as I am aware the latest official version does not support for loops. They were added in a separate branch of the project so are not officially recognized as vJASS by most people.
The syntax highlighters are separate from the pre-processor thus they also do not recognize it as vJASS.
Eerm are you 100% positive for loops can be used in vJass without using ZINC? Where did you read this?
The only refference I found was this: http://www.wc3c.net/vexorian/zincmanual.html "Factorial"
Isn't using normal loops a better solution?
Also u is undefined. You can not kill a unit that does not exist, nor check if a non-existing unit is within a unit group.
Perhaps something like this is what you are searching for?
JASS:
private function test takes nothing returns nothing
local unit u
local group g = CreateGroup()
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
//do something here
call GroupRemoveUnit(u)
endloop
call DestroyGroup(g)
set g = null
endfunction
Here I set u to be the first unit picked from the group, then do some actions with that unit,
then remove the unit from the group and so on untill there are no units in the group. Thus u = null.
As far as I am aware the latest official version does not support for loops. They were added in a separate branch of the project so are not officially recognized as vJASS by most people.
The syntax highlighters are separate from the pre-processor thus they also do not recognize it as vJASS.
I am using Cohadar's most recent version of JassHelper. Also, u doesn't need a value. When coding in vJass w/ a supporting pre-processor, doing
JASS:
for u in g
call KillUnit(u)
endfore
returns
JASS:
loop
set u = FirstOfGroup(g)
exitwhen u == null
call GroupRemoveUnit(g, u)
call KillUnit(u)
endloop
The use of for and endfor just clean up the script so it's slightly easier to read. It gets output to be the same. DSG answered my question best as I know realize that Cohadar's version won't be the original with syntax highlighting, and therefore the "for" and "endfor" keywords simply aren't going to be bold. Thank you both.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.