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 raddest synthwave tracks were chosen - Check out our Music Contest #12 - Results and congratulate the winners!
    Dismiss Notice
  4. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  5. Travel to distant realms and encounter scenes unknown to the common folk. The Greatest of Adventures is upon us with the 8th Cinematic Contest. Join in on a fun ride.
    Dismiss Notice
  6. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  7. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  8. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  9. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  10. 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.

Creating Custom Error Messages

Discussion in 'Trigger (GUI) Editor Tutorials' started by Faith, Apr 3, 2013.

  1. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    CREATING CUSTOM ERROR MESSAGES
    ~Created by Archange1



    REQUIREMENTS:
    • A medium-level understanding of the World Editor
    • Understanding variables and their use
    • The ability to read and process information

    CREDITS:
    • Vexorian
    • PurgeandFire111
    METHOD ONE

    A few things to take note of:
    • Not recommended - use method two if possible
    • Harder to use; more annoying than method two
    Step One:
    To start off, you're going to want to make three variables.
    These three variables will be used in method two as well, so you might as well make them now.

    Name Type Array
    ErrorSound Sound No
    ErrorMessage String No
    ErrorPlayer Player No

    - The sound variable is the sound played when the error message pops up.
    - The string variable is the message displayed when you tell it to appear.
    - The player variable is the player that the message is shown to.

    Step Two:
    Next you're going to find where you want your custom error message - what trigger you're going to use it for.
    Then copy this:

    • YourTrigger
      • Events
      • Conditions
      • Actions
        • Custom script: if udg_ErrorSound == null then
        • Custom script: set udg_ErrorSound = CreateSoundFromLabel( "InterfaceError",false,false,false,10,10)
        • Custom script: endif
        • Set ErrorMessage = YourMessage
        • Set ErrorPlayer = YourPlayer
        • Custom script: if GetLocalPlayer() == udg_ErrorPlayer then
        • Custom script: call ClearTextMessages()
        • Custom script: call DisplayTimedTextToPlayer( udg_ErrorPlayer, 0.52, 0.96, 2.00, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+udg_ErrorMessage+"|r" )
        • Custom script: call StartSound(udg_ErrorSound)
        • Custom script: endif


    Step Three:
    Now you're going to fill in those variables if you haven't already.

    Once again;
    - ErrorMessage is the message displayed when you tell it to appear.
    - ErrorPlayer is the player that the message is shown to.

    Once you have all that completed, you're done!

    METHOD TWO

    A few things to take note of:
    • Recommended method
    • Quick and simple to do
    • Doesn't tie up a lot of space in the trigger's actions
    Step One:
    If you haven't already, make the variables listed in method one.

    Step Two:
    In the trigger editor, go to your map header and enter the following code:

    Code (vJASS):
    function ErrorMessage takes string error, player whichPlayer returns nothing
        if udg_ErrorSound == null then
            set udg_ErrorSound = CreateSoundFromLabel("InterfaceError",false,false,false,10,10)
        endif
        set error = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+error+"|r"
        if GetLocalPlayer()==whichPlayer then
            call ClearTextMessages()
            call DisplayTimedTextToPlayer(whichPlayer,0.52,0.96,2,error)
            call StartSound(udg_ErrorSound)
        endif  
    endfunction


    Step Three:
    Next you're going to find where you want your custom error message - what trigger you're going to use it for.
    Then copy this:

    • YourTrigger
      • Events
      • Conditions
      • Actions
        • Set ErrorMessage = YourMessage
        • Set ErrorPlayer = YourPlayer
        • Custom script: call ErrorMessage(udg_ErrorMessage,udg_ErrorPlayer)


    Step Four:
    Now you're going to fill in those variables if you haven't already.

    Once again;
    - ErrorMessage is the message displayed when you tell it to appear.
    - ErrorPlayer is the player that the message is shown to.

    Once you have all that completed, you're done!

    ADDITIONALLY

    Keep in mind that the SimError is written in vJass, and Almia's tool has a complete different purpose.
     
    Last edited: Apr 3, 2013
  2. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,860
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
  3. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    Then make a tutorial. :D
    This is the basic side of it. It's only used to mimic the standard error messages, not keep track of them.

    For instance, if you cast frost armor on something that already has frost armor, you could make show an error message (like the "not enough lumber/gold" ones),
    showing that the unit already has frost armor, and then cancelling the ability or refunding mana or something.

    It looks like your system is used for debugging errors found within the map, while this is used only during play. It's not a REAL error, just the message.
    I think I over-explained that, but I wanted to be sure you saw the difference. ^^

    Correct me if I'm wrong.
     
  4. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,860
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    No no no.
    Im just linking it to you :D.
    Just say as an alternative but advanced way :D
     
  5. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    This is different tho. T_T
    Having the messages outside the game doesn't do much good.

    Screenshot
    [​IMG]


    This is what the system mimics.
     
  6. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,860
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    Okay ;_;
     
  7. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    I'd give you rep if I could, because I see what you were doing. ^^

    Unfortunately --> dat 24 hour thang. :c

    Thanks anyway. :)

    EDIT: I just realized while re-reading the tutorial that I put created by Archange1.
    The tutorial is, of course, but I DON'T claim credit for the system!
     
  8. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,860
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    How about linking SimError? Because that's where you got the idea :D
     
  9. -Kobas-

    -Kobas-

    Joined:
    Jan 17, 2010
    Messages:
    5,894
    Resources:
    28
    Icons:
    1
    Tools:
    2
    Maps:
    10
    Spells:
    4
    Template:
    5
    Tutorials:
    6
    Resources:
    28
    I think that there is no need for all that |n|n|n , correct me if I'm wrong, but you can set text X,Y on screen right?
     
  10. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    I wasn't aware of anything like this. x)
    Also this is a repost of PurgeandFire111's ideas, not mine.
    He just gave me permission to put it into a tutorial for others to see.

    I actually got the idea from PurgeandFire111. I've never seen SimError before in my life. ^^

    EDIT: Linked both at the bottom of the tutorial.
     
  11. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,427
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    @Kobas: The X-Y parts have limits on how far you can set it. (I don't remember if you can do negative values or not, correct me if I'm wrong) Also, it will move all previous text messages to that spot.

    This tutorial looks solid. :) Although, the system isn't really by me, so you can remove the credit about "~System by PurgeandFire".

    Approved.
     
  12. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    Alright will do I suppose. :s

    And thanks. :)
     
  13. Almia

    Almia

    Joined:
    Apr 24, 2012
    Messages:
    4,860
    Resources:
    35
    Spells:
    30
    Tutorials:
    4
    JASS:
    1
    Resources:
    35
    Okay nice tutorial :D
    + rep

    Useful for debugging purposes and/or some notifications :D
     
  14. Wintaer

    Wintaer

    Joined:
    Apr 10, 2013
    Messages:
    9
    Resources:
    0
    Resources:
    0
    Very nice tutorial lizzeh :)
     
  15. NewMapMaker

    NewMapMaker

    Joined:
    Apr 12, 2013
    Messages:
    8
    Resources:
    0
    Resources:
    0
    I like it. However I wouldn't really call it an "error message". Maybe I'd call it a "notification message", since error seems to bring to mind something like the program or map crashing :D

    Good job to all involved.
     
  16. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    Well it's titled error message, because the messages that are shown when: for example, you try to building something without enough gold; are called error messages.
     
  17. NewMapMaker

    NewMapMaker

    Joined:
    Apr 12, 2013
    Messages:
    8
    Resources:
    0
    Resources:
    0
    fair enough :) that makes sense... I guess "In-game Error Message" then, as opposed to "windows error message"...
     
  18. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,610
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    why dont use BJDebugMsg()?
     
  19. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    BjDebugMsg() has a different purpose entirely. It displays the text to all players for what, 60 seconds?

    It's useful for finding problems with triggering, but that's not what this does.
    This system is used for creating similar messages like the one below.
    Screenshot
    [​IMG]


    Unlike your average error messages, these are SUPPOSED to be in-game, as they tell the player some sort of information.
     
  20. Wintaer

    Wintaer

    Joined:
    Apr 10, 2013
    Messages:
    9
    Resources:
    0
    Resources:
    0
    BjDebugMsg will also give this

    Code (vJASS):
    function BJDebugMsg takes string msg returns nothing
        local integer i = 0
        loop
            call DisplayTimedTextToPlayer(Player(i),0,0,60,msg)
            set i = i + 1
            exitwhen i == bj_MAX_PLAYERS
        endloop
    endfunction
     

    While DisplayTextToPlayer will only give this small code
    Code (vJASS):
    native DisplayTextToPlayer takes player toPlayer, real x, real y, string message returns nothing