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

[JASS] call ExecuteFunc("")

Status
Not open for further replies.
JASS:
native ExecuteFunc takes string funcName returns nothing

Suppose this is called from an expired trigger - does the function being called register the trigger as GetTriggeringTrigger?

I think it might, since when an expired trigger performs the function TriggerExecute that executed trigger recognizes the original expired trigger as GetTriggeringTrigger...
 
For the most part, it should work. However, there might be some possibilities of failures (such as the ones DSG explained.).

I did a simple test and it works:
JASS:
scope TestExec initializer OnInit
private function A takes nothing returns nothing
    call BJDebugMsg(I2S(GetHandleId(GetTriggeringTrigger())))
    call TriggerSleepAction(5) // you can take this out, it should still work
    call ExecuteFunc("B")
    call ExecuteFunc("C")
endfunction
function B takes nothing returns nothing
    call BJDebugMsg("Function B: Executed.")
    call BJDebugMsg(I2S(GetHandleId(GetTriggeringTrigger())))
endfunction
private function OnInit takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterTimerEvent(t,1,false)
    call TriggerAddAction(t,function A)
endfunction
endscope
JASS:
scope TestingX initializer OnInit
function C takes nothing returns nothing
    call BJDebugMsg("Function C: Executed.")
    call BJDebugMsg(I2S(GetHandleId(GetTriggeringTrigger())))
endfunction
private function OnInit takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterTimerEvent(t,1,false)
    call TriggerAddAction(t,function C)
endfunction
endscope

Basically, it shows the id of the first two separate triggers:
1048689
1048692

Then it shows the triggering trigger when function B and C are executed. (After 5 seconds) Both returned "1048689", despite one being in a different trigger with the same event. (Although this can probably vary in some cases, none I can think of off the top of my head but I can't be too sure) Take out the TriggerSleepAction() and it should still work.

Just one note:
Don't make the "execute functions" private. Basically, execute func will not find the right function, and it should crash. That's why you need it to be a normal function. (or probably public) Well, that or you can use "ScopeName__funcname".
ex:
JASS:
    call ExecuteFunc("TestingX__C")
JASS:
private function C takes nothing returns nothing
    call BJDebugMsg("Function C: Executed.")
    call BJDebugMsg(I2S(GetHandleId(GetTriggeringTrigger())))
endfunction

Should work too.

EDIT: @Reborn: Yeah, my mistake. Fixed it, thanks =D
 
Last edited:
Status
Not open for further replies.
Top