- Joined
- Apr 24, 2012
- Messages
- 5,113
Use functions from other triggers [Standard JASS]
I. Introduction
This tutorial allows you to use the functions from other triggers.
There are problems we experience when we want to use other functions from other triggers.Examples is that we get syntax error when we try to use functions from other triggers with or without arguements. You will probably need a JNGP to use the functions without conflicts/problems that you will experience.
II. What are the problems?
This example of snippet will explain it.
We want to use the function MessageX to display messages, but the thing is that if we try to use this like this from other triggers :
III. The Solution
I discovered the solution when I tried to code a system using scripts. The solution to this problem is to use a simple snippet of function inside the Map Header(the top-of-the-script Script, located in the upper-most of the Trigger Editor with the map icon). We shall add a dummy function there so that we can use the functions properly. Example : Let's add this simple snippet of code :
So what does this do?
Nothing. But when a map header has a function inside it, it will allow any functions from the triggers to be used by external triggers.
Simple huh?
IV. Known bugs
You can experience some bugs when using this trick. Try removing any function in the map header while other triggers uses the functions from the external triggers.Enable/Disable the trigger that uses external functions (to check syntax), this won't show any syntax error.But when you tried to save the map, a syntax error message will show.
There is a bug also when attempting to move the scripts. The trigger you are going to move in must be the first trigger to be created on your map,or else you are doomed.
The solution to the problem is replacing your first trigger,then move all of the actions to a replica.Then move the scripts you want to the trigger replaced.
Note: All of the triggers in your map will be moved in the header,and then will be arranged based on how old they are in the Trigger Editor,starting from the oldest,which will be on top,and the newest,will be on the bottom.
I. Introduction
This tutorial allows you to use the functions from other triggers.
There are problems we experience when we want to use other functions from other triggers.Examples is that we get syntax error when we try to use functions from other triggers with or without arguements. You will probably need a JNGP to use the functions without conflicts/problems that you will experience.
II. What are the problems?
JASS:
function Message takes string s returns nothing
call BJDebugMsg(s)
endfunction
//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
set gg_trg_Untitled_Trigger_001 = CreateTrigger( )
endfunction
This example of snippet will explain it.
We want to use the function MessageX to display messages, but the thing is that if we try to use this like this from other triggers :
call Message("Hello")
, this will give us a syntax error " Expected a function name ".But if you use it inside the trigger it is located, it will work perfectly.III. The Solution
I discovered the solution when I tried to code a system using scripts. The solution to this problem is to use a simple snippet of function inside the Map Header(the top-of-the-script Script, located in the upper-most of the Trigger Editor with the map icon). We shall add a dummy function there so that we can use the functions properly. Example : Let's add this simple snippet of code :
JASS:
function EnableScriptUsage takes nothing returns nothing
endfunction
So what does this do?
Nothing. But when a map header has a function inside it, it will allow any functions from the triggers to be used by external triggers.
Simple huh?
IV. Known bugs
You can experience some bugs when using this trick. Try removing any function in the map header while other triggers uses the functions from the external triggers.Enable/Disable the trigger that uses external functions (to check syntax), this won't show any syntax error.But when you tried to save the map, a syntax error message will show.
There is a bug also when attempting to move the scripts. The trigger you are going to move in must be the first trigger to be created on your map,or else you are doomed.
The solution to the problem is replacing your first trigger,then move all of the actions to a replica.Then move the scripts you want to the trigger replaced.
Note: All of the triggers in your map will be moved in the header,and then will be arranged based on how old they are in the Trigger Editor,starting from the oldest,which will be on top,and the newest,will be on the bottom.
Last edited by a moderator: