HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

An example of a failed boolexpr in a register function event

06-09-2009, 07:55 PM#1
Troll-Brain
grim001 use it in his AutoIndex code.
I've never use a boolexpr in a register-event-function because i thought that Blizzard didn't finish them (did you see any use in blizzard.j ?), so it may have silly bugs. And we all known how they are fast to fixed known-bugs ...

It seems i was right.

Here is an example

Collapse JASS:
scope test initializer init

globals
    private integer I = 0
endglobals

private function Test takes nothing returns boolean
    // all the code here won't be called
    set I = 1
    call BJDebugMsg("this text won't be displayed")
    return false
endfunction

private function Conditions takes nothing returns boolean
    call BJDebugMsg("conditions ; I == " + I2S (I))
    return true
endfunction

private function Actions takes nothing returns nothing
    call BJDebugMsg("actions ; I == " + I2S (I))
endfunction

private function init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    local unit u = CreateUnit(Player(0),'Hpal',0.,0.,0.)
    
    call UnitAddItem(u,CreateItem('spsh',0.,0.))
    call TriggerRegisterPlayerUnitEvent(trig,Player(0),EVENT_PLAYER_UNIT_DROP_ITEM,Filter(function Test))
    call TriggerAddCondition(trig,Condition(function Conditions))
    call TriggerAddAction(trig,function Actions)
    
    call BJDebugMsg("just drop the item")
endfunction

endscope

So use them at your owns risk and test it if they so something ...

Btw i don't say grim001's code will fail, i know there is not an other way to handle it like that, but we don't have enough feedbacks and knowledge actually about using a such boolexpr, to assume it's perfectly safe.

I just want to point it out.
06-09-2009, 08:21 PM#2
Vexorian
It should be easy to know if it will work or not, I'd say it depends on the Event register native being used.
06-09-2009, 08:47 PM#3
Bobo_The_Kodo
In this case it doesn't matter, because the actions/conditions happen before the dropping occur