• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Run on map initialization?

Status
Not open for further replies.
Level 3
Joined
Apr 1, 2005
Messages
53
Hey, I'm currently learning jass and I guess I make some progress. Now I have a question though, and I don't see it answered so far.
As I read tutorials on this site, it said you should use a local variable for triggers, like local trigger t = createtrigger() etc.
Problem is, I need an initialization trigger and it will only run on initialization if I use no local variable. Does this matter in terms of leak? Is there another way? Maybe with vjass?
 
Level 14
Joined
Nov 20, 2005
Messages
1,156
The WE automatically creates and (if you tick the 'run on init box) executes a trigger with the name gg_trg_TRIGGERNAME. Set that global to the trigger and it'll work as you tried. But that's decapricated by vJass initialisers really. It should be noted that using InitTrig for lots of stuff is a bad idea, as all of the InitTrig functions share one thread, so crashing one crashes them all, and you could possibly eventually hit the op limit, causing loads of stuff to stop working (as it isn't inited).
 
Level 3
Joined
Apr 1, 2005
Messages
53
What do you mean with InitTrig? I thought every trigger needs to start with InitTrig_...?
Also, how would I go with vJass initializers then? I can't seem to find any advice on this on this site or in the JassHelper help.
 
JASS:
library YourScope initializer Init

private function Init takes nothing returns nothing
    // This will be executed in map initialization, or near it :P
endfunction

endlibrary

Every trigger NEEDS to have a function called InitTrig_YourTrigger. This function will be automatically executed while the map is being loaded, I think. That is, almost map initialization.

However, the trigger have actions/conditions which are functions as well. They are not needed, and are added to a trigger with the functions TriggerAddAction( trigger, code ) and TriggerAddCondition( trigger, boolexpr ). They will be executed when the trigger event occurs.

If you want those actions/conditions to be executed at map initialization, activate the box "Run at map initialization" above the text editor, in the trigger editor.
 
Level 14
Joined
Nov 20, 2005
Messages
1,156
Every trigger NEEDS to have a function called InitTrig_YourTrigger. This function will be automatically executed while the map is being loaded, I think. That is, almost map initialization.

Not true if using vJass. Also, InitTrigs come before map init.

If you want those actions/conditions to be executed at map initialization, activate the box "Run at map initialization" above the text editor, in the trigger editor.

Requires that you set it to the global WE expects it to be in.
 
Level 3
Joined
Apr 1, 2005
Messages
53
So if I would go the easy way and just use the global variable, as to say the WE version of a jass trigger, I could achieve my goal (as I knew already).
With vJass I would need a library, or what? I don't exactly get the point of them and all I want is to have my trigger executed on map init, nothing more. I don't want anything to go in the header or have requirements or something.
So what should I do? Would you recommend the library anyway?
 
Status
Not open for further replies.
Top