Command setup trigger?

Kazuga

Let the game begin...
Reaction score
110
Ok I have never understood how this thing works.. I want a trigger that when you write -x an integer variable will be set to the written number. I know this might be simple but I just never understand the logic of it..
 

the Lumpy

►►►
Reaction score
53
Here's a pretty basic way to do it:

Code:
Untitled Trigger 9001
    Events
        Player - Player 1 (Red) types a chat message containing - as A substring
    Conditions
    Actions
        Set entered_integer = (Integer((Substring((Entered chat string), 2, (Length of (Entered chat string))))))
        Set integers[(Player number of (Triggering player))] = entered_integer
integers is an integer array, so that you can store an integer for each player by using the player's number for the array index. You may not need it to be player-specific, in which case you could not make it an array. Other than that, it's pretty simple. You take everything in the string starting after the hyphen, convert it to an integer, and then store it in a variable.
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
715
Lets assume you have a string called "msg" which contains the following letters: "-gold 1000".

Now, if you want to use only the "1000" you'd have to "chop" it out of the string with the help of the "Substring" action.

"Substring(s, 7, length of(msg))"

The number 7 tells us from which letter the "chopping" process will begin and the "length of(msg)" tells us when to stop.

Now, if you count 7 letters from the begging of what the string "msg" contains, you get "-gold ", including the space between "-gold" and "1000", meaning you will start "chopping" the string from the letter "1" and stop until you reach the end of the message.

Obviously, you need a conversion to use the retrieved string as an integer.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top