What is it in JASS

Status
Not open for further replies.
This thread is about functions in GUI and their equivalent in JASS, although, I cant say its equivalent because there are natives and BJs functions.

What is the native equivalents of the following in JASS:

1)
  • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
    • Loop - Actions
2)
  • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Do nothing)
3)units in region matching condition AND units in region owned by player

If I remeber anything else I'll post it and thanks for any help in advance.
 
All group picking functions starts with GroupEnum***. There are few of them:

JASS:
    call GroupEnumUnitsInRange(pick_group, x, y, radius, FilterFunc)
    call GroupEnumUnitsInRect(pick_group, your_rect, FilterFunc)
    call GroupEnumUnitsOfPlayer(pick_group, Player(num), FilterFunc)

1. >>

JASS:
globals
  group gr = CreateGroup()
endglobals

// . . .
function Actions takes nothing returns nothing
  // some actions with GetEnumUnit()
endfunction

// . . .
call GroupEnumUnitsInRect(gr, bj_mapInitialPlayableArea, null)
call ForGroup(gr, function Actions)

2. >>

JASS:
globals
  group gr = CreateGroup()
endglobals

// . . .
call GroupEnumUnitsInRect(gr, bj_mapInitialPlayableArea, null)
// . . .

3. >>

JASS:
globals
  group gr = CreateGroup()
endglobals

// . . .
// picking all units of player 0 (equal to Player 1 Red in GUI)...
// ...and with custom value equal to 0 (this is custom condition)
function FilterFunc takes nothing returns boolean
  return GetOwningPlayer(GetFilterUnit()) == Player(0) and GetUnitUserData(GetFilterUnit()) == 0
endfunction

// . . .
local rect my_rect = Rect(-192, -192, 192, 192)
// . . .
call GroupEnumUnitsInRect(gr, my_rect, Filter(function FilterFunc))
// . . .
call RemoveRect(my_rect)
set my_rect = null

>> EDIT <<

Oh, by the way, use TESH or JassCraft to display code of BJ functions. Unwrapping BJs is the way to natives.
 
a boolexpr is a function that returns a boolean, for example:

JASS:
function someFunction takes nothing returns boolean
    return true
endfunction

And how you use it:
JASS:
call GroupEnumUnitsOfTypeCounted(yourGroup, "string", Condition(function someFunction), 5)
 
BJ functions are usally functions who calls native functions

eg.

JASS:
function UnitAddAbilityBJ takes integer abilityId, unit whichUnit returns boolean
    return UnitAddAbility(whichUnit, abilityId)
endfunction

which just calls

JASS:
native UnitAddAbility takes unit whichUnit, integer abilityId returns boolean
 
Status
Not open for further replies.
Back
Top