• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

map init

Status
Not open for further replies.
Level 8
Joined
Nov 9, 2008
Messages
502
Ok. So I'm writing my whole script into 1 trigger (whatever you call those things in the list on the left) like the pros do ^^ but I got a question.

If triggers are set to run at map init they load code during the map load so if I were writing all into 1 trigger how could I set a particular function to run at map init? If I just selected that box at that top, wouldn't that run all the functions in that trigger?
 
Level 11
Joined
Feb 22, 2006
Messages
752
So I'm writing my whole script into 1 trigger (whatever you call those things in the list on the left) like the pros do ^^

No...they dont. There's no point in putting all your code into one trigger.

how could I set a particular function to run at map init?

If you have vJass, use scope/library initializers. If you don't, then use the InitTrig functions in every trigger; they are run at map initialization.
 
Level 8
Joined
Nov 9, 2008
Messages
502
I have vJass but still, I'm very much a noob without knowledge of Scopes or Librares. Maybe you would be so kind as to explain how to use them for this purpose.

In any case....this is the init to creat that trigger and I can call functions inside there which will run on init?

Example:
JASS:
function InitTrig_Script takes nothing returns nothing
    set gg_trg_Script = CreateTrigger(  )
    set gg_trg_SetGlobals = CreateTrigger(  )
    call TriggerAddAction( gg_trg_SetGlobals, function SetGlobals )
    call SetGlobals()
endfunction
Correct?

A couple other questions:
  1. gg_trg_ is always necessary?
  2. if I create a global in a global block rather than using the GUI, must I reference it with udg_ prefix?
  3. it doesn't at least look cooler in 1 trigger?
 
Level 8
Joined
Nov 9, 2008
Messages
502
Oh ok thankyou. So it was a misconception of mine that pros put all script into 1 trigger. Maybe the result of looking at hacked map codes. Isn't that what the compiler does anyway (put all triggers into 1 script)?

I just checked info about libraries....
Example:
JASS:
library a initializer PreLoad
    call PreLoad
endlibrary
Correct? If function PreLoad is below the library it will still run?

Man I really don't get this. Neither methods are working for me.
 
Last edited:
Level 11
Joined
Feb 22, 2006
Messages
752
Initializers have to be inside the library and scope to which they belong. So:

JASS:
library A initializer init

private function init takes nothing returns nothing
    // this function will be run on map init
endfunction

endlibrary

scope A initializer init

private function init takes nothing returns nothing
    // this function will be run on map init
endfunction

endscope
 
Level 8
Joined
Nov 9, 2008
Messages
502
Ohh so to declare a function is to write it out in full there and it must be within the library/scope. I assume as it's running on map init there's no difference between using a scope or a library.

Will try it out thanks for that.
 
Level 8
Joined
Feb 15, 2009
Messages
463
gg_trg_ is the prefix, so, yes, required.
globals are referred as udg indeed, since udg(lobal)_.

This is bullshit sorry

the gg_trg just stands for a editor created type u can find for example again in gg_rct for rects

you can always make a trigger local like

JASS:
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerAddAction( t , function ...)
endfunction
endscope

or just grab them from a local stack

JASS:
globals
    trigger array spell [200] //size of 200 for example
endglobals

private function Init takes nothing returns nothing
set spell[0] = CreateTrigger()
call TriggerAddAction( spell[0] , function ...)
endfunction
endscope

if u want everything in one trigger(without the multiple scope library inits) u have to split the Inits coz only one init is called per trigger( in my case i dont know if its everywhere same but at me it just takes one) , so u have to make it like


JASS:
private function Init takes nothing returns nothing
     call Init1()
     call Init2()
   .
   .
   .
endfunction

so much to say... Saia
 
Status
Not open for further replies.
Top