1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[JASS] Natives and Local variables ...

Discussion in 'Triggers & Scripts' started by mckill2009, Feb 26, 2011.

  1. chobibo

    chobibo

    Joined:
    Sep 24, 2005
    Messages:
    2,701
    Resources:
    0
    Resources:
    0
    TestCast can't have the same name, it's a public function; the other one inside the library block is.
     
  2. mckill2009

    mckill2009

    Joined:
    Mar 10, 2009
    Messages:
    4,696
    Resources:
    34
    Maps:
    5
    Spells:
    27
    JASS:
    2
    Resources:
    34
    @Chobibo

    No it's not, I've learned a lot from your spell...
    But your spell did use 'private' but still I got an error, but it's OK now...maybe it needs
    Library as Fingolfin said?...

    @Fingolfin

    1. So is library and scope the same?...
    2. Can 'globals and endglobals' be IN a library/scopes?...
    3. The function onCast can be used as a 'DIFFERENT' onCast function 'OUTSIDE' a library?...
    4. Can you declare private without library/scope?...
    5. Where did you get the 'MySpell', is it a name or an event?...
    6. Can global declarations be used outside a library/scope?...

    THANKS +rep to all
     
  3. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    ZINC isn't harder to read if you're used to C as it got a C-liker syntax. Almost more common to normal scripting code languages.

    1. No it isnt. Libraries are compiled first and can have "requires/uses/needs" + another library's name. This will 'cause the required library to be compiled before the other library thus the second library gaining access to the first one.

    Scopes are compiled after libraries and cannot have this "needs" as you cannot require a scope. A scope is just a code block, usually for normal map code and spells, not systems which are prefered to put into a library (because of the compile order).

    Code (vJASS):
    library something requires anotherlibrarywhichhasthisname, thisisanotherlibraryseperatedwithacoma

    scope something requires willgiveyouasyntaxerror


    2. Can be declared anywhere while not inside a struct, function, method but can be inside scope and library.

    3. I'm not sure about this one. As you usually make something private because it shouldnt interfere with other functions in other libraries. Make it public if you want to use it else where.

    4. I think you can, not sure though.

    5. The name of the library or scope is totally up to you. HAve to be unique and not be the same as any other scope or it will throw up a syntax error.

    6. Same as 4.
     
  4. chobibo

    chobibo

    Joined:
    Sep 24, 2005
    Messages:
    2,701
    Resources:
    0
    Resources:
    0
    It needs to be inside a scope, since it's a spell.

    1. No. Libraries has the highest priority when initializing script, scopes are initialized according to the order they are arranged on the trigger editor. This means that all libraries get initialized first before scopes, library initialization order is also different, a library required by another library takes higher priority.
    2. Yes.
    3. If onCast is private and inside a scope or a library, having a duplicate onCast function will be valid.
    4. No. The point of having libraries and scopes is that you can encapsulate (hide) your code inside a block from the entire code.
    5. User-defined library identifier. Just type what you want as a name, as long as the characters you're using are valid (underscores aren't valid).
    6. Yes, as long as you're using NewGen to save the said map, or you're using the command line parser of jasshelper.
     
  5. mckill2009

    mckill2009

    Joined:
    Mar 10, 2009
    Messages:
    4,696
    Resources:
    34
    Maps:
    5
    Spells:
    27
    JASS:
    2
    Resources:
    34
    @Baassee, Chobibo

    But libraries and scopes have similarities?...meaning >>> blocking...

    When I pressed Syntax check, it has errors but when I saved the map and
    cast the spell, it's OK, it it always the case?...

    EDIT:

    this...

    what if I use private function onCast in a library/scope and use another private function onCast in another library/scope...will it still be valid?...

    hehe...sorry guys if I have too many questions :)...
     
  6. chobibo

    chobibo

    Joined:
    Sep 24, 2005
    Messages:
    2,701
    Resources:
    0
    Resources:
    0
    The only similarities they have is the way they are declared and the ability to hide the script within itself from the whole script.

    Don't use the syntax check button, it uses pjass to parse the script, which doesn't recognize vjass. You need to save the map so that jasshelper (vjass parser) can check the script. vjass errors will pop up if there are any, intercepting the save command.

    Yes, that's why it's called private, so that other libraries or scopes can't call it. If they can't call it, then it can contain the same function.
     
    Last edited: Mar 9, 2011
  7. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,036
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Yeah the Syntax Check button is obsolete, I don't know if it's something Vexorian has the ability to change but NewGen hasn't even been updated with the latest JassHelper built-in, so I doubt will ever see an update to it.
     
  8. mckill2009

    mckill2009

    Joined:
    Mar 10, 2009
    Messages:
    4,696
    Resources:
    34
    Maps:
    5
    Spells:
    27
    JASS:
    2
    Resources:
    34
    Well I hope one of you guys will update the NewGen for the sake of new users of it...
     
  9. chobibo

    chobibo

    Joined:
    Sep 24, 2005
    Messages:
    2,701
    Resources:
    0
    Resources:
    0
    Count me out, I'm still learning pointers in C++ lol.
     
  10. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    @baassee - well if you have background on C, yeah, but for someone like me who has no background in any programming language (other than JASS/vJASS/ZINC and well a bit of html, a long time ago...), its definitely harder to read than vJASS...

    @mckill - well, if someone could... but i guess it needs permission from Vexorian first... ^_^
     
  11. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    Or we aren't * enough. Just save the map with ctrl + s...

    Yeah adik I know, I learned a bit C++ and ruby afterwards so now it's easier :p
     
    Last edited by a moderator: Mar 12, 2011
  12. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    I never clicked that Syntax Check button... ^_^
     
  13. chobibo

    chobibo

    Joined:
    Sep 24, 2005
    Messages:
    2,701
    Resources:
    0
    Resources:
    0
    pjass (Syntax Check) is functional for normal jass. I still use it for non-vjass scripts.
    That was too harsh dude, he's just starting to learn.
     
    Last edited by a moderator: Mar 12, 2011
  14. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    Isn't PJASS used after JASSHelper has compiled? As you get PJASS errors for forgetting an endif or stuff like that.

    I may be but it's always better to be straight and clear about things.
     
  15. Garfield1337

    Garfield1337

    Joined:
    Jul 6, 2009
    Messages:
    1,806
    Resources:
    4
    Maps:
    1
    Spells:
    3
    Resources:
    4
    Hmm..since you're discussing vJASS may i ask a question?

    What's the difference between public function and just function?
    If a function is in a library,you can call it from any trigger so i don't see the difference...

    I assume though,that the public functions receive a different name (or a prefix) upon compiling so it doesn't interfere with other functions,but i'm not sure...

    Also what's the difference when using libraries and scopes?
     
  16. chobibo

    chobibo

    Joined:
    Sep 24, 2005
    Messages:
    2,701
    Resources:
    0
    Resources:
    0
    Yes, it's the same pjass that the syntax check button uses to parse script. Also, Vexorian added an alternative script parser, clijasshelper.
     
  17. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,220
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    a public function are prefixed NAME_functionname

    normal functions can bug with the names that's why you usually go with public functions (although I don't)

    libraries are usually for greater things such as systems, scopes are for the rest but you can make spells in a library though doesnt matter, it's just the order they compile that matters
     
  18. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,191
    Resources:
    153
    Models:
    143
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    153
    As i might have said earlier, if you are unsure about anything regarding vJass, it is always best to read the JassHelper Manual first. It can be found in the JassHelper folder inside the JNGP directory, though i've attached it to this post incase you couldn't find it. It includes all basic information about how the features work and how you should use them.
     

    Attached Files:

  19. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    or check the vJASS manual on the net... ^_^
     
  20. mckill2009

    mckill2009

    Joined:
    Mar 10, 2009
    Messages:
    4,696
    Resources:
    34
    Maps:
    5
    Spells:
    27
    JASS:
    2
    Resources:
    34
    Hello it's me again guys...

    1. In GUI when you save using hashtable, you set the ID and then add to a unit group...then set the ID again inside that unit group, then load...so how do you do it in JASS/vJASS?...

    2. When using HT, is it not necessary to use "TriggerRegisterTimerEventPeriodic"?...