Calling functions between triggers?

Nevyll

New Member
Reaction score
1
Hai, I'm working on a hero picking system, but I've come across a problem; whenever I try to call a function between 2 triggers, it gives me a "Expected Function Name" error :banghead:

I put the function "StartPick" in a trigger above the Start Pick trigger:

JASS:
function StartPick takes nothing returns nothing
endfunction

function InitTrig_Pick_Hero_Functions takes nothing returns nothing
endfunction


And when I try to call the StartPick function, it gives me errors :(

JASS:
function Trig_Start_Pick_Actions takes nothing returns nothing
    call StartPick()
endfunction

function InitTrig_Start_Pick takes nothing returns nothing
    set gg_trg_Start_Pick = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Start_Pick, function Trig_Start_Pick_Actions )
endfunction


Thanks in advance!
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
You can't refer to functions between triggers, at least not in the manner you're trying. :(

With the unmodified World Editor, you can put functions in the map header (click the map name in the Trigger Editor), and then they can be called from any other trigger.

If you're using the Jass NewGen Pack (Windows only), you can put your functions in a library or something like that, and I think it'll let you call them between triggers. :confused:

As a last resort, you can use [ljass]ExecuteFunc("NameOfYourFunction")[/ljass], but this has the risk of crashing your map if the function in question does not exist, does not allow you to pass parameters, and sometimes is corrupted if you intend to optimize your map before release (because it changes function names and may not find this reference).
 

Nevyll

New Member
Reaction score
1
Ah, yeah, I've heard of the ExecuteFunc() and the Map Header option, but I'm trying to avoid those :confused:

The reason I want to have it this way is because of readability and such, and I've seen in maps like the Azeroth Grand Prix and the Dota 6.32 Open Objects that Blizzard and IceFrog respectively(?) uses some triggers as collection of functions; the "core" trigger on DotA for example.
 

kissmenow21

New Member
Reaction score
0
I was looking for the exact same thing.
I guess putting the functions in the header makes the functions global.
But I want to know how you can export and import functions.
I don't want my million lines of function code all jammed into my header.
Can someone answer???
 

Bribe

vJass errors are legion
Reaction score
67
You can't call functions between trigger slots in World Editor? Wow, I've forgotten how insanely bad its syntax checker was. JassHelper utterly destroys the old limitations of JASS.
 

saw792

Is known to say things. That is all.
Reaction score
280
You can't call functions between trigger slots in World Editor? Wow, I've forgotten how insanely bad its syntax checker was. JassHelper utterly destroys the old limitations of JASS.

You can, unreliably. The order at which GUI "Triggers" appear in your final map script is completely different to the order they are listed in the Trigger Editor. Something to do with order of creation I think. Anyway, you might get lucky once, then you might save your map again and it won't work because the order has changed. The map header is there for a reason. If you don't like it then you had better get Newgen.
 

Sammmet

New Member
Reaction score
0
You can declare the function in the map stuff thing and with
function Sleep takes (whatever) return (whatever)
endfunction
then you can create a function in the trigger u want that does what u want. u will have the function in the map section but it will be in the trigger u want to. I have made a map with it but dont know how to upload.
 

tooltiperror

Super Moderator
Reaction score
231
Of course, if you want, you can use libraries if you use JassHelper.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top