Question about a filter for filtering a group to a specific type

Technomancer

New Member
Reaction score
14
Ok so here's the function in question:

Code:
function UnitTypeEquals takes unit un, unittype utype returns boolean
    return GetUnitTypeID(un) == utype
endfunction

I copied it and modified it from a dummy GUI script I put together (to get the JASS code) but I need to apply it to a general function that doesn't have a triggering unit. How do I pass what unit I want to compare, or grab that unit from the following function? ( GetUnitsInRectMatchin( ... ) )

Here's the call to the function:

Code:
    set g = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function UnitTypeEquals('h003'))

I have no unit to pass as of the call because they need to be assigned to a group.






So basically what I want to do is select all units of one type and can't figure out how to do it in GUI or JASS (JASS preferred) because I can't figure out how to grab the unit being checked in the checking function.
 

Technomancer

New Member
Reaction score
14
Is it GetFilterUnit()? If so ummm delete thread plx

Edit:New code, giving me a missing parenthesis error or something...

JASS:
function UnitTypeEquals takes integer utype returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == utype )
endfunction

//in a later function
    set g = GetUnitsInRectMatching( GetPlayableMapRect() , Condition( function UnitTypeEquals('h003') ) )


Final Edit: using a better function solves all problems.

I feel like an idiot here, I think I have the syntax right from what I've seen and the debugging I've done in the last 20 minutes.
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
You cannot use argument intakes in such functions.

Whether create a suitable condition function which takes nothing or use globals to pass the information.

function IsUnitFootman takes nothing returns boolean
- return GetUnitTypeId(GetFilterUnit()) == 'hfoo'
endfunction



globals
- unit UNIT_FILTER
- integer UNIT_TYPE
endglobals

function UnitTypeEquals takes nothing returns boolean
- return GetUnitTypeId(UNIT_FILTER) == UNIT_TYPE
endfunction


And some pseudo code,

...
...
- set UNIT_FILTER = GetFilterUnit()
- set UNIT_TYPE = 'hfoo'
- call GroupEnumUnitsInRect(g, rect, Condition(function UnitTypeEquals))

...
...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top