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] Learning JASS. Last Question

Discussion in 'Triggers & Scripts' started by Starquizer, Jun 9, 2009.

  1. Starquizer

    Starquizer

    Joined:
    Mar 3, 2006
    Messages:
    1,526
    Resources:
    6
    Maps:
    1
    Spells:
    2
    Tutorials:
    3
    Resources:
    6
    OK, then how do you learn then; I really can't understand Vexorian's table. Do I need to understand how it works or I just take it as it is (which is a thing I don't like, like when some of my collegues tell me that I apply an equation as it is without understanding it, Sorry if that has drifted away from the subject)
     
  2. Element of Water

    Element of Water

    Joined:
    Aug 3, 2008
    Messages:
    2,298
    Resources:
    5
    Spells:
    3
    Tutorials:
    1
    JASS:
    1
    Resources:
    5
    Table works by using method operators to make an easy interface for a kind of unlimited array which can store use any handle as an index. It basically retrieves the handle id of the given index and uses that to store or retrieve a value in a hashtable.
     
  3. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    When it comes to using libraries, you need to know how to use them, not how they work internally. Now, knowing how they work can be interesting, but knowing how to use them is the only thing you really *need* to know. How they work won't help you when it comes to problem solving. Especially in "early" stages of learning a language, you should know how to use it. If you become more experienced you may get to understand how it works behind the scenes.

    Nevertheless, feel free to ask more *specific* questions related to how Table works. Or how to use it, in case you don't know that either.
     
  4. Starquizer

    Starquizer

    Joined:
    Mar 3, 2006
    Messages:
    1,526
    Resources:
    6
    Maps:
    1
    Spells:
    2
    Tutorials:
    3
    Resources:
    6
    In the table I found text macros, when I tried to learn how to use them I make a function using them but I get a syntax error. The function is like that:

    Code (vJASS):
     
    //! textmacro TextMacroName takes DISPTEXT
    function Message$DISPTEXT$ takes nothing returns nothing
        Call DisplayTimedTextToPlayer(Player(0),0,0,10,"$DISPTEXT$ Test" )
    endfunction
    //! endtextmacro
    function exe takes nothing returns nothing
        //! runtextmacro TextMacroName("Integer")
        //! runtextmacro TextMacroName("Real")
        //! runtextmacro TextMacroName("Unit")
    endfunction
    function InitTrig_text_macro takes nothing returns nothing
        local trigger t = CreateTrigger(  )
        call TriggerRegisterPlayerChatEvent(t,Player(0),"tm",false)
        call TriggerAddAction(t, function exe )
    endfunction
     


    What error did I made ?
     
  5. Vulcano

    Vulcano

    Joined:
    Mar 8, 2009
    Messages:
    335
    Resources:
    1
    Maps:
    1
    Resources:
    1
    I never used textmacros but i just read a tutorial about it.
    I think this will work:

    EDIT: You must just change "Integer" into Integer
     
  6. Starquizer

    Starquizer

    Joined:
    Mar 3, 2006
    Messages:
    1,526
    Resources:
    6
    Maps:
    1
    Spells:
    2
    Tutorials:
    3
    Resources:
    6
    Sorry, not working either.
     
  7. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    "Call" should be "call", with lowercase c.

    Another mistake you made is running your textmacro inside a function.
    This is what happens when a textmacro is compiled:

    Everything between
    //! textmacro blabla

    and
    //! endtextmacro

    is copied into each line containing
    //! runtextmacro blabla
    , and the parameters are being replaced.

    In your example, this is how your resulting code looks like:
    Code (vJASS):

    function exe takes nothing returns nothing
        function MessageInteger takes nothing returns nothing
            call DisplayTimedTextToPlayer(Player(0),0,0,10,"Integer Test" )
        endfunction
        function MessageReal takes nothing returns nothing
            call DisplayTimedTextToPlayer(Player(0),0,0,10,"Real Test" )
        endfunction
        function MessageUnit takes nothing returns nothing
            call DisplayTimedTextToPlayer(Player(0),0,0,10,"Unit Test" )
        endfunction
    endfunction
    function InitTrig_text_macro takes nothing returns nothing
        local trigger t = CreateTrigger(  )
        call TriggerRegisterPlayerChatEvent(t,Player(0),"tm",false)
        call TriggerAddAction(t, function exe )
    endfunction


    As you can see, the actual textmacro is removed, and each //! runtextmacro line is replaced by the code written in the textmacro.
    In this case, you have written 3 functions INSIDE a function, which is obviously not allowed.
     
  8. Starquizer

    Starquizer

    Joined:
    Mar 3, 2006
    Messages:
    1,526
    Resources:
    6
    Maps:
    1
    Spells:
    2
    Tutorials:
    3
    Resources:
    6
    I have changed it to that:

    Code (vJASS):
     
    //! textmacro TextMacroName takes DISPTEXT
        call DisplayTimedTextToPlayer(Player(0),0,0,10,"$DISPTEXT$ Test" )
    //! endtextmacro
    function exe takes nothing returns nothing
        //! runtextmacro TextMacroName("Integer")
        //! runtextmacro TextMacroName("Real")
        //! runtextmacro TextMacroName("Unit")
    endfunction
    function InitTrig_text_macro takes nothing returns nothing
        local trigger t = CreateTrigger(  )
        call TriggerRegisterPlayerChatEvent(t,Player(0),"tm",false)
        call TriggerAddAction(t, function exe )
    endfunction
     


    Now its working, thanks to your detailed explanation, Eleandor.
     
  9. kennyman94

    kennyman94

    Joined:
    Nov 22, 2009
    Messages:
    181
    Resources:
    0
    Resources:
    0
    This is so true. i was stumped and thought a function was the same as a trigger.
     
  10. kennyman94

    kennyman94

    Joined:
    Nov 22, 2009
    Messages:
    181
    Resources:
    0
    Resources:
    0
    does Jass NewGen Pack v5d work for v1.24.1.6374 of wc3?
     
  11. Destroyer95

    Destroyer95

    Joined:
    Jul 28, 2008
    Messages:
    207
    Resources:
    3
    Spells:
    3
    Resources:
    3
    Yes it does.

    By the way, do you know how old this thread is? xD
    It's from 3-4 months ago :O
     
  12. Element of Water

    Element of Water

    Joined:
    Aug 3, 2008
    Messages:
    2,298
    Resources:
    5
    Spells:
    3
    Tutorials:
    1
    JASS:
    1
    Resources:
    5
    Nah, only 2.5 months ago. But still. And don't double post. Use edit.
     
  13. Destroyer95

    Destroyer95

    Joined:
    Jul 28, 2008
    Messages:
    207
    Resources:
    3
    Spells:
    3
    Resources:
    3
    Thanks for correcting me xD
    Wasn't paying much attention. Anyway since the post is here again I have a question. Does Starquizer come online now? He helped me a while ago and maybe he could do it again xD
     
  14. Starquizer

    Starquizer

    Joined:
    Mar 3, 2006
    Messages:
    1,526
    Resources:
    6
    Maps:
    1
    Spells:
    2
    Tutorials:
    3
    Resources:
    6
    Yes, I am still there.

    But I am just busy with my studies. So my JASS may need some refreshments.
     
  15. Destroyer95

    Destroyer95

    Joined:
    Jul 28, 2008
    Messages:
    207
    Resources:
    3
    Spells:
    3
    Resources:
    3
    Yea, I took a 2 month brake from jass some time ago and when I came back I forgot a lot of things, but it didn't take long to get back.
     
  16. kennyman94

    kennyman94

    Joined:
    Nov 22, 2009
    Messages:
    181
    Resources:
    0
    Resources:
    0
    ty i did not know how old this was.