Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[JASS] vJass, the new generation

Discussion in 'Triggers & Scripts' started by UnMi, May 8, 2007.

  1. UnMi

    UnMi

    Joined:
    Feb 16, 2006
    Messages:
    149
    Resources:
    1
    Maps:
    1
    Resources:
    1
    http://www.wc3campaigns.net/showthread.php?t=91491
    Those who doubted about the speed or stability of Handle Vars, here is the solution!
    Although you actually still use Handle Var in some cases, this is supposed to be 4 times faster than Handle Vars. Worth taking a look at, I guess.
     
  2. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    It's faster, as far as I've gotten results-wise, as well as being less buggy

    Also, you can use Timer Stacks as an alternative to having to pass structs through a gamecache

    It's also really nice for things such as Inventory Systems
     
  3. wyrmlord

    wyrmlord

    Joined:
    Oct 13, 2005
    Messages:
    252
    Resources:
    5
    Tools:
    1
    Maps:
    1
    Tutorials:
    3
    Resources:
    5
    I prefer WeWarlock over vJass. It comes with pretty much any system I need, including classes, ways to attach info to timers/items/units with direct array access (preprocessor does this), and a bunch of other useful things.
     
  4. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    Kewl. I may get around to playing with it some time or another X_x
     
  5. UnMi

    UnMi

    Joined:
    Feb 16, 2006
    Messages:
    149
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Could you explain that? What are Timer Stacks? =.=;
     
  6. wyrmlord

    wyrmlord

    Joined:
    Oct 13, 2005
    Messages:
    252
    Resources:
    5
    Tools:
    1
    Maps:
    1
    Tutorials:
    3
    Resources:
    5
    I'll send you the same PM I sent Poot about them.

    Just for a little more advertising, WeWarlock has a timer stack (or whatever you'd like to call it) system built into it known as SmartTimers.
     
    Last edited: May 9, 2007
  7. Diablo-dk

    Diablo-dk

    Joined:
    Nov 10, 2004
    Messages:
    369
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    hmm..well, it had to happen some day that someone would post this here, though i stick to use handle vars on THW as it is more understandable for the most jassers we got here, since THW havent got as many advanced jassers like wc3c.

    But maybe it is time to show people here that JASS preprocessers are much more effective than handle vars and such things.
     
  8. UnMi

    UnMi

    Joined:
    Feb 16, 2006
    Messages:
    149
    Resources:
    1
    Maps:
    1
    Resources:
    1
    The tutorial should be good and understandable enough, althought it's not quite complete yet.
    I still don't know what libaries/scopes/methods are >>;...
     
  9. Vexorian

    Vexorian

    Joined:
    Mar 11, 2004
    Messages:
    649
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Using a timer stack mostly means you are doing things the wrong way.

    For those 0.01~0.04 timeout timers used for animations you certainly don't need them

    And for the other timers with bigger delays used for cleaning effects and to call functions after a time, you don't need more than 2 timers during the whole game.

    Well that's the logic behind TimeLib which you may find at : http://www.wc3campaigns.net/showthread.php?t=93785

    TimeLib simply says "don't attach stuff to timers, it is not needed" . And well, it saves a lot of hassle.

    With timer stacks you need to be careful about double frees, you may add protection against them in the timer stack functions but I think that it should also be possible to have the timer as a member of an struct, the only thing required would be to have a way to get the struct from GetExpiredTimer() but it is an over complication to use timers this way.

    And well, this is the reason vJass is not biased towards any library since stuff seem to get better with the time, so adding a lot of syntax to feature some kind of library more easily is not worth it since they tend to get obsolete with time.
     
    Last edited: May 9, 2007
  10. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,131
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Vexorian, could you please post a easy to DL link to this program, I can not download it from wc3c due to some anti link protection, even if i axcess and browse wc3c directly. Also the links in wc3c are messed up, they link me to random pages on the fourm. . .
     
  11. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    UnMi --

    Libraries; can require other libraries, can hold private members, and bump their script to the top of the map. Can also have initializers.

    Eg.

    Code (vJASS):
    //Yayz! We're above even the Custom Script section!
    library PieLib initializer PieInit needs CSCache //I need CSCache!
        private function Pie takes nothing returns nothing
            //Haha! I can only be called by functions inside PieLib
        endfunction
        function PieInit takes nothing returns nothing
            //Haha! I'm called on map init
        endfunction
    endlibrary


    That's basically libraries in a nutshell.

    Scopes are basically just the Private option in libraries (correct me if they can have initializers). Eg.

    Code (vJASS):
    scope HidingCriminals
        private function Criminal takes nothing returns nothing
            //O_o the police can't get me!
        endfunction
        globals
             private string secretHideoutLocation = "Elm Street"//I'm also safe!
        endglobals
        private struct passwords
             string lastWeek = "camel"
             string thisWeek = "spam"
            //can't touch this!
        endstruct
    endscope

    function Police takes nothing returns nothing
        call Criminal()
        //Darn! It doesn't work! Where could those criminals have gone?
    endfunction


    Finally, methods are functions within structs. Eg.

    Code (vJASS):
    struct Pie
        integer numPies
        real percentCherry = .05
        method AddCherries takes real percent returns nothing
            set this.percentCherry = this.percentCherry + percent
        endmethod
    endstruct

    function TestPie takes nothing returns nothing
        local Pie dat = Pie.create()
        set dat.numPies = 3
        call dat.AddCherries()
    endfunction
     
    Last edited: May 9, 2007
  12. UnMi

    UnMi

    Joined:
    Feb 16, 2006
    Messages:
    149
    Resources:
    1
    Maps:
    1
    Resources:
    1
    LOL! You should become a teach in the primary school >>;...
    Well, I see now, thanks a lot!
    But...now where is the use of libaries/scopes? Are they like for easier importing? Why not just use the header?
    The methods are very useful...
     
  13. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    Have fun with your posts, that's my philosophy :p

    (as long as they're not spammy)

    Libraries(/scopes) are mostly for

    -Cheating with initializer functions (libraries)

    -Making code that you want others to use, but have bits that only you should be able to touch (private, library/scope)

    -not ever having to use the header again (libraries).
    It's alot nicer to be able to organize your stuff in a 'Funcs' folder and just dump each thing in a seperate "trigger", rather than having to scroll through 10s of 1000s of lines of the header

    Also, libraries can have scopes, but libraries can't have libraries. I also think scopes can have scopes, but don't quote me on that one
     
    Last edited: May 9, 2007
  14. Jacek

    Jacek

    Joined:
    Nov 25, 2004
    Messages:
    1,291
    Resources:
    0
    Resources:
    0
    handle vars + normal jass > this anyway
     
  15. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    Nah, this can do alot of different things. It's also a helluva lot less buggy
     
  16. wyrmlord

    wyrmlord

    Joined:
    Oct 13, 2005
    Messages:
    252
    Resources:
    5
    Tools:
    1
    Maps:
    1
    Tutorials:
    3
    Resources:
    5
    Using preprocessors makes your code faster if you use them for storing as you're only storing a single integer instead of many different values. Also, OOP syntax just makes everything look cooler, and can be much easier to use.:wink:
     
  17. Vexorian

    Vexorian

    Joined:
    Mar 11, 2004
    Messages:
    649
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Jacek, it is fine that you are vintage and won't take accept that things change, but could you please tell me how handle vars could replace "this way"? Purplepoot has been discussing a lot of things that are simply not related to what handle vars do.

    Aren't you the same guy that said is unable to read long spell code? libraries or wewarlocks require have been invented because code organization is important, you do have a brain and should know the difference between coding a game using only one syntax file and using multiple syntax files with correct placing for code that has specific uses.

    In regards to storage, I am also afraid that handle vars are an extremely overcomplicated way to do things that ends up doing them in the most unsafe and slow way possible, thus ever using handle vars makes you look bad, if you are afraid that using tools may make you look weak, then use the normal Jass you love so much, notice that handle vars are in no way "normal Jass", and that you could pretty much replace them with clever array usage. Of course, the post fix syntax of arrays may make the code look pretty bad, but that's the reason you are using "normal jass".

    And if this a single case of the NIH syndrome, nothing stops you from making your own preprocessor.

    ..
    scopes can have child scopes, although I am yet to find an use for that...

    Dr. Super Good: Fix your browser's cookies or get a browser without bugged cookies. Or enable cookies.
     
  18. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,131
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    You think I did not try that?
     
  19. Vexorian

    Vexorian

    Joined:
    Mar 11, 2004
    Messages:
    649
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Else I don't have any other logical explanation.
     
  20. Zergleb

    Zergleb

    Joined:
    Dec 14, 2004
    Messages:
    84
    Resources:
    1
    Maps:
    1
    Resources:
    1
    oops didn't read second page(accident) and what I had posted before my edit had already been said.