1. Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.
    Dismiss Notice
  2. A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!
    Dismiss Notice
  3. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[vJASS] Need Some Help, Please

Discussion in 'Warcraft Editing Tools' started by Starquizer, Apr 11, 2009.

  1. Starquizer

    Starquizer

    Joined:
    Mar 3, 2006
    Messages:
    1,526
    Resources:
    6
    Maps:
    1
    Spells:
    2
    Tutorials:
    3
    Resources:
    6
    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: Apr 11, 2009
  2. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    The underlined line means that you can't, for example, initialize a global variable like this:

    Code (vJASS):
    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.
     
  3. Starquizer

    Starquizer

    Joined:
    Mar 3, 2006
    Messages:
    1,526
    Resources:
    6
    Maps:
    1
    Spells:
    2
    Tutorials:
    3
    Resources:
    6
    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 ?
     
  4. TriggerHappy

    TriggerHappy

    Code Moderator

    Joined:
    Jun 23, 2007
    Messages:
    3,833
    Resources:
    22
    Spells:
    11
    Tutorials:
    2
    JASS:
    9
    Resources:
    22
    I think you have the wrong idea of initializers.

    What they do is run the function on map initialization, so you can create events and things of that sort.
     
  5. Starquizer

    Starquizer

    Joined:
    Mar 3, 2006
    Messages:
    1,526
    Resources:
    6
    Maps:
    1
    Spells:
    2
    Tutorials:
    3
    Resources:
    6
    Can you give an example, please ?
     
  6. TriggerHappy

    TriggerHappy

    Code Moderator

    Joined:
    Jun 23, 2007
    Messages:
    3,833
    Resources:
    22
    Spells:
    11
    Tutorials:
    2
    JASS:
    9
    Resources:
    22
    Code (vJASS):

    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
     
     
  7. Starquizer

    Starquizer

    Joined:
    Mar 3, 2006
    Messages:
    1,526
    Resources:
    6
    Maps:
    1
    Spells:
    2
    Tutorials:
    3
    Resources:
    6
    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" ?
     
  8. TriggerHappy

    TriggerHappy

    Code Moderator

    Joined:
    Jun 23, 2007
    Messages:
    3,833
    Resources:
    22
    Spells:
    11
    Tutorials:
    2
    JASS:
    9
    Resources:
    22
    A function won't be ran until you call it, or setup an event with it.

    All an initializer does is run the function MapInit (loading screen).
     
  9. Starquizer

    Starquizer

    Joined:
    Mar 3, 2006
    Messages:
    1,526
    Resources:
    6
    Maps:
    1
    Spells:
    2
    Tutorials:
    3
    Resources:
    6
    Sorry, but I don't understand :confused:
     
  10. TriggerHappy

    TriggerHappy

    Code Moderator

    Joined:
    Jun 23, 2007
    Messages:
    3,833
    Resources:
    22
    Spells:
    11
    Tutorials:
    2
    JASS:
    9
    Resources:
    22
    Whats there not to understand..

    The init is run at map initialization... jeez.
     
  11. Yixx

    Yixx

    Joined:
    Oct 12, 2008
    Messages:
    1,492
    Resources:
    3
    Spells:
    3
    Resources:
    3
    Code (vJASS):
    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
    '
    Code (vJASS):
    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,,
     
  12. Starquizer

    Starquizer

    Joined:
    Mar 3, 2006
    Messages:
    1,526
    Resources:
    6
    Maps:
    1
    Spells:
    2
    Tutorials:
    3
    Resources:
    6
    Must it be used in a library ?
     
  13. TriggerHappy

    TriggerHappy

    Code Moderator

    Joined:
    Jun 23, 2007
    Messages:
    3,833
    Resources:
    22
    Spells:
    11
    Tutorials:
    2
    JASS:
    9
    Resources:
    22
    In a library or a scope.
     
  14. Starquizer

    Starquizer

    Joined:
    Mar 3, 2006
    Messages:
    1,526
    Resources:
    6
    Maps:
    1
    Spells:
    2
    Tutorials:
    3
    Resources:
    6
    What does library_once do ? And what exactly is Textmacro ?
     
  15. TriggerHappy

    TriggerHappy

    Code Moderator

    Joined:
    Jun 23, 2007
    Messages:
    3,833
    Resources:
    22
    Spells:
    11
    Tutorials:
    2
    JASS:
    9
    Resources:
    22
    The JassHelper manual will tell you the answer two both of those.
     
  16. Starquizer

    Starquizer

    Joined:
    Mar 3, 2006
    Messages:
    1,526
    Resources:
    6
    Maps:
    1
    Spells:
    2
    Tutorials:
    3
    Resources:
    6
    Through reading the vJASS manual I found that vJASS is a tool that doesn't add new functions instead it organizes these functions in the script. Is that right ?
     
  17. busterkomo

    busterkomo

    Joined:
    Jun 17, 2007
    Messages:
    1,423
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    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.
     
  18. aznricepuff

    aznricepuff

    Joined:
    Feb 22, 2006
    Messages:
    749
    Resources:
    4
    Maps:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    4
    Of course JASS is compiled. There's no way computers could run a language like JASS from text efficiently. Way too much effort just to avoid compiling a pretty standard scripting language.
     
  19. Starquizer

    Starquizer

    Joined:
    Mar 3, 2006
    Messages:
    1,526
    Resources:
    6
    Maps:
    1
    Spells:
    2
    Tutorials:
    3
    Resources:
    6
    So that means that you still need to handle and learn JASS to understand how vJASS works. At first I thought that vJASS is a different scripting language from normal JASS, but I see I was wrong.
     
  20. TriggerHappy

    TriggerHappy

    Code Moderator

    Joined:
    Jun 23, 2007
    Messages:
    3,833
    Resources:
    22
    Spells:
    11
    Tutorials:
    2
    JASS:
    9
    Resources:
    22
    vJASS is just an extension of JASS.