HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Init and InitTrig

03-05-2011, 02:09 AM#1
DanThanh
Could you please tell me the difference between these triggers:
Just because some of my triggers do not run

Collapse JASS:
scope HeroRevive initializer Init

private function Init takes nothing returns nothing
endfunction

endscope

Collapse JASS:
scope HeroRevive

private function InitTrig  takes nothing returns nothing
endfunction

endscope
03-05-2011, 02:16 AM#2
moyack
Those are two ways to do the same.... as far as I remember
03-05-2011, 02:16 AM#3
Fledermaus
If a function is called InitTrig_*TRIGGER_NAME* it will be turned into an initialization trigger (run at map init) by the WE. Jasshelper turns all initializer decelerations into initializer triggers (they run at slightly different times to the default WE's initialization triggers but that doesn't really matter for scopes).

Your scopes with an initializer will run but your ones without one and a private function InitTrig wont be turned into initialization triggers by the WE because jasshelper ass the private prefix of SCOPENAME___. Either use initializers or switch the private keyword to public as jasshelper has a special case where it will turn any public InitTrig trigger into InitTrig_SCORPENAME (which makes it an initialization trigger).

I would recommend using initializers as it looks nicer and if you change the trigger name you don't have to change the scope name too.
03-05-2011, 05:57 AM#4
DanThanh
Very clearly, thanks Fledermaus. btw, do i need to tick "Run on map Initialization" for my VJass triggers?
But i'm still embarrassed, as some of my triggers never run. It seems they have never existed in my map.
I use mainly VJass code for my map, and all triggers look like this:

Collapse JASS:
scope HeroRevive

public function InitTrig  takes nothing returns nothing
endfunction

endscope

Then i want more heroes, so i create some new trigger, but they just simply do not fire. I try the other way:

Collapse JASS:
scope HeroRevive initializer Init

private function Init takes nothing returns nothing
endfunction

endscope

This time they work normally but then some old trigger stop working, i don't know why
03-06-2011, 07:37 AM#5
Fledermaus
Na, you don't need to tick that.

The public function InitTrig might not be working because the trigger has a different name from the scope. No idea why other stuff stops working though..
03-06-2011, 06:51 PM#6
Anitarf
If I remember correctly, scope initializers are not run using ExecuteFunc like library initializers are, so they are not immune to thread limit being hit. If too many scope initializers do too much stuff, the thread might reach the op limit before all of them are done executing. This is pure speculation, as I have no idea whether your map is anywhere close to hitting the op limit on initialization or not. However, if this is the problem, then it should be fixable by changing a few scopes that do a lot of stuff on initialization into libraries.

The "public function InitTrig" is an old relic from a time when we did not yet have scope and library initializers. Although it probably still works, you shouldn't be using this old feature any more; if you changed all your scopes to use proper initializers, then the map would probably be easier to debug.
03-07-2011, 11:31 AM#7
DanThanh
Quote:
Originally Posted by Anitarf
If I remember correctly, scope initializers are not run using ExecuteFunc like library initializers are, so they are not immune to thread limit being hit. If too many scope initializers do too much stuff, the thread might reach the op limit before all of them are done executing. This is pure speculation, as I have no idea whether your map is anywhere close to hitting the op limit on initialization or not. However, if this is the problem, then it should be fixable by changing a few scopes that do a lot of stuff on initialization into libraries.

The "public function InitTrig" is an old relic from a time when we did not yet have scope and library initializers. Although it probably still works, you shouldn't be using this old feature any more; if you changed all your scopes to use proper initializers, then the map would probably be easier to debug.

You are my savior, i love you so much