• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[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