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 haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. From the gates of hell, the 5th Special Effect Contest Results have emerged.
    Dismiss Notice
  4. Rubbed the right way, the genie is out of its lamp! The 12th Concept Art Contest Results have been announced.
    Dismiss Notice
  5. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Do you have good ideas for new contests? If so, please open new threads in the Contest Submission sub-forum to discuss them.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

A Collection of GUI Systems > Basic to Advanced (Incomplete)

Discussion in 'Trigger (GUI) Editor Tutorials' started by Kwah, Aug 28, 2008.

  1. Kwah

    Kwah

    Joined:
    May 9, 2007
    Messages:
    3,391
    Resources:
    8
    Icons:
    5
    Maps:
    1
    Tutorials:
    2
    Resources:
    8
    Is a collection of GUI, systems that I have refined throughout my GUI career. I'm now moving on to JASS, and thought that I would share some of this knowledge. I plan to have a large collection of systems. I realize that a few of these may already be done, but I believe that mine are improvements/refinements in some cases.

    If there is a specific topic you are interested in having covered, please just tell me and I'll do my best.

    Completed Systems:

    * Setting Integers Through Chat (Completed)


    In Development:

    * Victory Conditions 101


    Setting Integers Through Chat

    Setting Integers Through Chat


    This tutorial teaches and explains how to construct a system, that when the player types a chat string, followed by a collection of numbers, a variable is set to the value of the entered numbers. I'll explain how to add a cap to the maximum as well. This tutorial is very simple but goes into a lot of detail. Remember to add a space after "-number "

    Variables



    • YourInteger
    • And Later: YourInteger[]


    Poorly Done Version


    • Trigger
      • Events
        • Player - Player 1 (Red) types a chat message containing -number as A substring
      • Conditions
      • Actions
        • Set YourInteger = (Integer((Substring((Entered chat string), 9, 12))))
        • Game - Display to (Player group((Triggering player))) the text: (YourInteger now = + (String(YourInteger)))


    De-Construction


    Is a simple way of doing it. Now, I'll de-construct it, explain and improve.

    • Player - Player 1 (Red) types a chat message containing -number as A substring


    Is rather simple really. If the player (1 red in this case) types a chat message, containing the string "-number " then the event will trigger. This is not foolproof, so don't go rushing off yet.

    • Set YourInteger = (Integer((Substring((Entered chat string), 9, 12))))


    Sets YourInteger (a integer variable) to the substring of the entered chat string. In this case it picks all of the characters, in between, 9 and 12 of your message, and converts them to an integer. If there are non-integer characters in this area (ie: a or b) it will ignore them.

    • (Game - Display to (Player group((Triggering player))) the text: (YourInteger now = + (String(YourInteger)))


    Just, displays a message so that you know you got it right.


    Getting Better!


    There are however some issues with this message. What I will revise it to will look like this:

    • Trigger
      • Events
        • Player - Player 1 (Red) types a chat message containing -number as A substring
        • Player - Player 2 (Blue) types a chat message containing -number as A substring
        • Player - Player 3 (Teal) types a chat message containing -number as A substring
        • Player - Player 4 (Purple) types a chat message containing -number as A substring
        • Player - Player 5 (Yellow) types a chat message containing -number as A substring
        • Player - Player 6 (Orange) types a chat message containing -number as A substring
        • Player - Player 7 (Green) types a chat message containing -number as A substring
        • Player - Player 8 (Pink) types a chat message containing -number as A substring
        • Player - Player 9 (Gray) types a chat message containing -number as A substring
        • Player - Player 10 (Light Blue) types a chat message containing -number as A substring
        • Player - Player 11 (Dark Green) types a chat message containing -number as A substring
        • Player - Player 12 (Brown) types a chat message containing -number as A substring
      • Conditions
        • (Substring((Entered chat string), 1, 8)) Equal to -number
      • Actions
        • Set YourInteger[(Player number of (Triggering player))] = (Integer((Substring((Entered chat string), 9, 12))))
        • Game - Display to (Player group((Triggering player))) the text: ((|c00FFFF00 + (String(YourInteger[(Player number of (Triggering player))]))) + |r)


    Before you try to do this the first thing you need to go is to go to your variables (ctrl-D). Click on the array box and set "Size = # of players in your map"

    De-Construction


    Now, I'll break it down again.

    • Events
      • Player - Player 1 (Red) types a chat message containing -number as A substring
      • Player - Player 2 (Blue) types a chat message containing -number as A substring
      • Player - Player 3 (Teal) types a chat message containing -number as A substring
      • Player - Player 4 (Purple) types a chat message containing -number as A substring
      • Player - Player 5 (Yellow) types a chat message containing -number as A substring
      • Player - Player 6 (Orange) types a chat message containing -number as A substring
      • Player - Player 7 (Green) types a chat message containing -number as A substring
      • Player - Player 8 (Pink) types a chat message containing -number as A substring
      • Player - Player 9 (Gray) types a chat message containing -number as A substring
      • Player - Player 10 (Light Blue) types a chat message containing -number as A substring
      • Player - Player 11 (Dark Green) types a chat message containing -number as A substring
      • Player - Player 12 (Brown) types a chat message containing -number as A substring


    Just checks for all of the players exactly what it did for Player One in the first trigger. Remember to add a space after the "-number"

    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Substring((Entered chat string), 1, 8)) Equal to -number


    This checks if the substring 1-8 ("-number ") actually says "-number ". This prevents players typing things like "10 -number ".

    • Then - Actions
      • Set YourInteger[(Player number of (Triggering player))] = (Integer((Substring((Entered chat string), 9, 12))))


    And, now we get to the actions. This does the same thing as, before but with an array added. This means that they're are actually 12 different variables (One for each player). This means that each player can set their own YourInteger.

    • Game - Display to (Player group((Triggering player))) the text: ((|c00FFFF00 + (String(YourInteger[(Player number of (Triggering player))]))) + |r)


    And, now we display the message. This time with pretty colour. use concatenate strings, and the colour codes on either side of the variable string.

    Adding a Ceiling


    Now, one last thing:

    Adding a ceiling.

    • Trigger
      • Events
        • Player - Player 1 (Red) types a chat message containing -number as A substring
        • Player - Player 2 (Blue) types a chat message containing -number as A substring
        • Player - Player 3 (Teal) types a chat message containing -number as A substring
        • Player - Player 4 (Purple) types a chat message containing -number as A substring
        • Player - Player 5 (Yellow) types a chat message containing -number as A substring
        • Player - Player 6 (Orange) types a chat message containing -number as A substring
        • Player - Player 7 (Green) types a chat message containing -number as A substring
        • Player - Player 8 (Pink) types a chat message containing -number as A substring
        • Player - Player 9 (Gray) types a chat message containing -number as A substring
        • Player - Player 10 (Light Blue) types a chat message containing -number as A substring
        • Player - Player 11 (Dark Green) types a chat message containing -number as A substring
        • Player - Player 12 (Brown) types a chat message containing -number as A substring
      • Conditions
        • (Substring((Entered chat string), 1, 8)) Equal to -number
      • Actions
        • Set YourInteger[(Player number of (Triggering player))] = (Integer((Substring((Entered chat string), 8, 99))))
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • YourInteger[(Player number of (Triggering player))] Greater than or equal to 500
          • Then - Actions
            • Set YourInteger[(Player number of (Triggering player))] = 500
            • Game - Display to (Player group((Triggering player))) the text: ((|c00FFFF00 + (String(YourInteger[(Player number of (Triggering player))]))) + |r)
          • Else - Actions
            • Set YourInteger[(Player number of (Triggering player))] = (Integer((Substring((Entered chat string), 9, 12))))
            • Game - Display to (Player group((Triggering player))) the text: ((|c00FFFF00 + (String(YourInteger[(Player number of (Triggering player))]))) + |r)


    De-Construction


    Lets take a more detailed look.

    • If - Conditions
      • YourInteger[(Player number of (Triggering player))] Greater than to 5000
      • Then - Actions
        • Set YourInteger[(Player number of (Triggering player))] = 5000


    Simply, if <YouInteger>[Trigger Player Number] is larger than 5000, it resets it to 5000.

    With the addition of a simple if/then/else the ceiling (maximum value) is added. If you want it so that it has no effect, then just leave the area blank. Instead of re-setting the variable.


    Additional Notes


    You could replace the integer with a real if you wanted, just change the variable type and all of the conversions.

    This wraps up my tutorial here. I hope that you enjoyed it, and that you find it useful. If you think that I need to improve something, or have found a bug, then please contact me.

    Thanks to PurplePoot for pointing out a further refinement.

    Changelog


    ~Updated Demo Map. Now has add gold, and spawn.
    ~Changed if/then/else to condition
    ~Fixed Error with order of ceiling in demo


    ~hawk900
     

    Attached Files:

    Last edited: Aug 29, 2008
  2. James7

    James7

    Joined:
    Dec 3, 2005
    Messages:
    479
    Resources:
    5
    Maps:
    5
    Resources:
    5
    I request a Alliance system that utilized Dialogs to inform someone that someone wishes to be thier ally.

    Example:

    Player 1: -ally blue

    *displays dialog to player blue saying: Player 1 would like to ally you, do you accept?*

    Answers: Yes or No

    But if you unally it just unallies both people no dialogs involved.
     
  3. Kwah

    Kwah

    Joined:
    May 9, 2007
    Messages:
    3,391
    Resources:
    8
    Icons:
    5
    Maps:
    1
    Tutorials:
    2
    Resources:
    8
    Ahha!

    A good idea.

    The questions is: should it be blue, or just 2. I can do blue.
     
  4. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    You could always do both.

    --check for colours
    --if fails, check for playernames?
    --if fails, check for numbers
     
  5. Kwah

    Kwah

    Joined:
    May 9, 2007
    Messages:
    3,391
    Resources:
    8
    Icons:
    5
    Maps:
    1
    Tutorials:
    2
    Resources:
    8
    Good Idea. I'll get on that I guess. The colour is going to be a little bit annoying, but no big deal.