• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] call functions from other trigs

Status
Not open for further replies.
Level 22
Joined
Dec 31, 2006
Messages
2,216
It's easy to access functions in other triggers.
If you had a trigger "a" with a function "x" and want to access that function in trigger "b" then just set it like this:

Trigger a:
JASS:
function x takes blablabla returns blablabla
...............
endfunction

Trigger b:
JASS:
function blabla takes blablabla returns blablabla
    call x()
endfunction
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
It worked for me.
All I did was:
1. First make trigger a and trigger b.
2. Then I saved it as .w3x.
3. Then I added the function x.
4. Then I made the other function that used function x.
5. Then I saved again and I got no errors.
Also remember to have trigger a above trigger b
 
Level 11
Joined
Feb 18, 2004
Messages
394
http://wc3campaigns.net/vexorian/jasshelpermanual.html#lib

functions in JASS must be defined above where they are used, unless you do some trickery with things such as ExecuteFunc() or with triggers. Libraries allow you to move arbitrary sections of code to the top of the map script, ordering different libraries to require one another.

There is also the custom script header, but its usage is considered deprecated due to libraries.

As for "triggers" and how they get ordered in the map script: I'm unaware of the specifics of which triggers will go first in the map script, but it likely has to do with creation order or something screwed up such as that. Thus, just use vJASS and libraries...
 
Status
Not open for further replies.
Top