- Joined
- Feb 2, 2006
- Messages
- 1,568
Hi,
recently I have been using GUI triggers a lot in maps instead of the scripting languages and it helped me a lot to use two patterns: The first is to use temporary global variables to emulate trigger parameters and the second is to use temporary global variables as local variables inside of triggers.
For example in the following trigger:
It could go even further and allow you to run a trigger only with its required parameters. I hope this does not cause data races since the trigger should be executed immediately and I use no waits inside.
Another thing which helped me using such tmp variables was to concatenate long strings over multiple lines or calculating complicated integer/real values over multiple lines. Sometimes I just set the temporary variables in the beginning of the trigger like the TmpPlayer to use it in the whole trigger which makes the actions much cleaner.
Didn't the Starcraft editor have triggers with parameters or local variables inside of triggers? Is there any reason why Warcraft 3 doesn't have this. I have never looked at the triggers from the original campaign but I could imagine that they use the same pattern. It allows you to call the same trigger from different other triggers changing the parameters, so basically like functions in JASS.
Do you have any idea why there are no default temporary global variables for every type? They only did this for something like the loop integers A and B
It would really help to have these default global variables for almost every type or to define local variables inside of triggers in the beginning, especially for standard types like strings, ints etc. it can be useful.
I guess it could only be achieved with a custom trigger editor GUI?
recently I have been using GUI triggers a lot in maps instead of the scripting languages and it helped me a lot to use two patterns: The first is to use temporary global variables to emulate trigger parameters and the second is to use temporary global variables as local variables inside of triggers.
For example in the following trigger:
-
Spawn From Barracks
-
Events
- Time - SpawnTimer expires
- Conditions
-
Actions
-
Unit Group - Pick every unit in AllBarracks and do (Actions)
-
Loop - Actions
- Set VariableSet TmpUnit = (Picked unit)
- Set VariableSet TmpPlayer = (Owner of TmpUnit)
- Trigger - Run Spawn Unit Types from Barrack <gen> (checking conditions)
-
Loop - Actions
-
Unit Group - Pick every unit in AllBarracks and do (Actions)
-
Events
It could go even further and allow you to run a trigger only with its required parameters. I hope this does not cause data races since the trigger should be executed immediately and I use no waits inside.
Another thing which helped me using such tmp variables was to concatenate long strings over multiple lines or calculating complicated integer/real values over multiple lines. Sometimes I just set the temporary variables in the beginning of the trigger like the TmpPlayer to use it in the whole trigger which makes the actions much cleaner.
Didn't the Starcraft editor have triggers with parameters or local variables inside of triggers? Is there any reason why Warcraft 3 doesn't have this. I have never looked at the triggers from the original campaign but I could imagine that they use the same pattern. It allows you to call the same trigger from different other triggers changing the parameters, so basically like functions in JASS.
Do you have any idea why there are no default temporary global variables for every type? They only did this for something like the loop integers A and B
It would really help to have these default global variables for almost every type or to define local variables inside of triggers in the beginning, especially for standard types like strings, ints etc. it can be useful.
I guess it could only be achieved with a custom trigger editor GUI?