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

[vJASS] Need Some Help, Please

Status
Not open for further replies.
Level 16
Joined
Mar 3, 2006
Messages
1,564
I don't understand these lines in JassHelperManual:

Will now work without any error, there is one limitation though, you can't use functions or non-constant values in the default value, for example you can make a global start on null, 1 , 19923 , 0xFFF, true, false, "Hi" , etc. But you can't make them initialize with any function call or with a native

This line is about Globals and how to declare them.

ADD

I don't also understand how Initializers work, and I don't understand the example in JassHelperManual.
 
Last edited:
Level 21
Joined
Aug 21, 2005
Messages
3,699
The underlined line means that you can't, for example, initialize a global variable like this:

JASS:
globals
    unit u = CreateUnit('h000', Player(0), ...)
    location loc = Location(0.0, 0.0)
    // You can, however, say:
    real r = 5.0
    // but then again, you can't say:
    real s = GetLocationX(loc)
endglobals

library initializers are functions that automatically run when you're loading the map. Their purpose is very clear: initializing a library, for example by setting global variables correctly, such as opening a new game cache.
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
library initializers are functions that automatically run when you're loading the map. Their purpose is very clear: initializing a library, for example by setting global variables correctly, such as opening a new game cache.

Why would I need them if the library function moves the function atop of the script. When I say Library B needs A; A will be atop B so what is the function of the Initializers ?
 
JASS:
scope ScopeName initializer InitTrig

    private function Actions takes nothing returns nothing
        
    endfunction

    //===========================================================================
    private function InitTrig takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterTimerEvent( t, 1.00, false)
        call TriggerAddAction( t, function Actions )
    endfunction

endscope
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
JASS:
scope ScopeName initializer InitTrig
 
    private function Actions takes nothing returns nothing
 
    endfunction
 
    //===========================================================================
    private function InitTrig takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterTimerEvent( t, 1.00, false)
        call TriggerAddAction( t, function Actions )
    endfunction
 
endscope

Ok. Suppose I have another function, lets say "TrigA" written before this one in your example, using Initialize will make the function InitTrig to run before "TrigA" ?
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
JASS:
library lib1 initializer Init
function Create takes nothing returns nothing
    // do something
endfunction
function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    // add events, actions, conditions etc,,
endfunction
endlibrary
This says 'initializer Init' , which means when loading (on loading screen) it will look for the function 'Init' in the library and run in,, that is why you create triggers and add events in that trigger
'
JASS:
library lib1 initializer LolZorsFunction
function Create takes nothing returns nothing
    // do something
endfunction
function LolZorsFunction takes nothing returns nothing
    local trigger t = CreateTrigger()
    // add events, actions, conditions etc,,
endfunction
endlibrary
this says 'initializer LolZorsFunction' ,, so on loading (loading screen) it will look for the function 'LolZorsFunction' and run it, this is where you create triggers and add events,,

Understand? If not,, you should read the above again and again,, i explained it clearly,,
the name behind 'initializer' gives the function name of the function that should run on map initialization,, so when loading screen is on the screen,, you can call it anything,, but most people find it usefull to just call it 'Init' to show it is the Initialization trigger for the library,,
 
Level 17
Joined
Jun 17, 2007
Messages
1,433
Yes, vJASS doesn't actually add anything to the JASS language. All vJASS is compiled (althought I'm not sure JASS is ever actually compiled) into standard JASS after the map is saved. If you have a simple syntax error in something like a struct, you can read the post-converted script in the pjass window that opens.
 
Status
Not open for further replies.
Top