• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

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

Level 24
Joined
May 9, 2007
Messages
3,563
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


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.



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


~hawk900
 

Attachments

  • SettingIntegersThroughChat.w3x
    16.8 KB · Views: 554
Last edited:
Level 13
Joined
Dec 3, 2005
Messages
501
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.
 
Top