• 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.

[General] How to make an array of boolexpr?

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,338
Hi,

For some reason it seems to be the case you can't have arrays of code.

But nothing is said about arrays of boolexpr. If I make a boolexpr, how do I put it into an array or other data structure?
 
Level 15
Joined
Aug 7, 2013
Messages
1,338
I need them for dynamic quest making and other things.

But can you tell me why I can't have both a filter and a condition??

Edit: Nevermind. My logic was right, but I didn't know that you have to call "GetFilterUnit()."

I searched all night for a goddarn tutorial on filters and couldn't find any. If I had just known that I'd have solved this problem ages ago. All works now >_>

JASS:
        call TriggerRegisterEnterRegion(t, goalRegion, playerRegionFilters[pid])
        //call TriggerAddCondition(t, playerRegionFilters[pid])
        call TriggerAddCondition(t, Condition(function regionEnterMain))

here is my filter function

JASS:
function p1RegionFilter takes nothing returns boolean
    local unit u = GetTriggerUnit()
    local player p = GetOwningPlayer(u)
    if p == players[0] then
        return true
    endif
    return false
endfunction
...
    set playerRegionFilters[0] = Filter(function p1RegionFilter)
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
^He is right.
JASS:
function p1RegionFilter takes nothing returns boolean
    local unit u = GetTriggerUnit()
    local player p = GetOwningPlayer(u)
    if p == players[0] then
        return true
    endif
    return false
endfunction
->
return GetOwningPlayer(GetTriggerUnit()) == player[0]
Btw in the function you wrote you leak ^^
 
Level 15
Joined
Aug 7, 2013
Messages
1,338
Here is the version of the filter that works. It has to be true before the condition holds, and yes it's inside an array of boolexpr too.

I didn't fix any leaks because I was in a rush to get functionality. First get something to work, THEN optimize it in my opinion...

JASS:
function p1RegionFilter takes nothing returns boolean
    local unit u = GetFilterUnit()
    local player p = GetOwningPlayer(u)
    if p == players[0] then
       set u = null
       set p = null
       return true
    endif
    set u = null
    set p = null
    return false
endfunction
 
Status
Not open for further replies.
Top