• 🏆 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!

one init trigger vs many

Status
Not open for further replies.
Level 21
Joined
Mar 29, 2020
Messages
1,237
hey there,

I heard somewhere that it is better to have one "map init" trigger all together than many separate ones. Is this true? shouldn't the code just run through all of them anyways (If they are all together I guess I set the order, but that shouldn't usually matter here... ). is this just to reduce the filesize by whatever tiny amount that having more triggers adds?

thanks!
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,893
It's not about going full 8 or 80.
One of more initialization triggers won't make such a difference, but in my opinion it is way better for someone to have 1 initialiazation trigger but then run other triggers that initialization other aspects of the map. This is what I call organization and structure, so you don't find it a hassle to find what you want to do in that long ass Initialization trigger. It is basically the same as having multiple triggers with initialization "event" but has more advantages.
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
you stated the advantages of a. having one init trigger that turns on a bunch of other triggers, over b. having one huge trigger with everything in it.

As far as I can tell, you did not explain why a.(see above) is better than c. having a separate "map init" trigger for each thing you need to happen at map init.
 
Given how World Editor works, Map Initialization ordering is, if I recall correctly, from the oldest to newest created trigger. This is a potential problem if you have a system that supposed to initialize mid-way of the initialization list and used by ones that are created before said system available (thus initialized before the system). It's not a common problem, but one can consider such a thing if they want to be extreme with their codes.
 
Level 9
Joined
Mar 26, 2017
Messages
376
I created a test map and extracted the custom script. Looks like the ordering is actually based on the order of the trigger inside the editor, rather than creation datetime.

Code:
function InitCustomTriggers takes nothing returns nothing
    call InitTrig_Melee_Initialization_Copy()
    call InitTrig_Melee_Initialization()
endfunction
 
I created a test map and extracted the custom script. Looks like the ordering is actually based on the order of the trigger inside the editor, rather than creation datetime.

Code:
function InitCustomTriggers takes nothing returns nothing
    call InitTrig_Melee_Initialization_Copy()
    call InitTrig_Melee_Initialization()
endfunction

Interesting. That means there's almost no benefit except added readability for having one Map Init trigger that dictates the rest.
 
Level 9
Joined
Mar 26, 2017
Messages
376
Interesting. That means there's almost no benefit except added readability for having one Map Init trigger that dictates the rest.
Would seem even easier to me to simply have 'Initalization' as event, because then you know when the actions are started, instead of having to have knowledge what is in other triggers.


does the trigger "frame" add filesize? (more triggers = larger file/consolidated triggers = smaller file), bc that would at least be something...even if probably a matter of a few single bytes...
If you care so much about optimization, then why not use custom script :p
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
If you care so much about optimization, then why not use custom script :p
this thread was started more out of curiosity than practicality.

I'm just trying to understand if there is any redeeming value in making only one init trigger, bc I have seen a lot of people insist it is better, even though from here it seems like it's just a matter of organizational priority.
 
Level 9
Joined
Mar 26, 2017
Messages
376
If you make one giant trigger, instead of multiple ones. It has a slightly lower filesize and less executions, but this is negligible.
This is reflected in the extra lines that are generated in the map script 'trigger frame'. And the executions performed for trigger activations.

This micro-optimization is entirely lost if you make multiple triggers. Regardless if they each have the 'Initalization' event, or if one activates the other within the trigger actions.
 
Status
Not open for further replies.
Top