HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Chat strings

07-18-2006, 04:07 AM#1
Hemlock
I tried to make a trigger that will make you type the hero level of the hero with the following trigger.

Trigger:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Entered chat string) Equal to (-level + (String((Integer((Entered chat string))))))
Collapse Then - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Hero level of MainUnit) Equal to (Integer((Entered chat string)))
Collapse Then - Actions
Game - Display to (All players) for 0.25 seconds the text: |cffff0000Error: Un...
Collapse Else - Actions
Hero - Set MainUnit Hero-level to (Integer((Entered chat string))), Show level-up graphics
Game - Display to (All players) for 0.50 seconds the text: (Hero has now been set to level |cffffcc00 + ((String((Integer((Entered chat string))))) + |r))
Else - Actions

it just happen to not launch the trigger at all, I had a pre-feeling that this wasn't going to work.

nonetheless, suggestion for this?
07-18-2006, 04:20 AM#2
SentryIII
Pointing out the obvious, I don't see any events. Make an event for each player that can do this that runs the trigger when they type "-level " as a substring. That's the best answer I can give you with what you posted.
07-18-2006, 05:18 AM#3
Hemlock
the event looks like this

Trigger:
Player - Player 1 (Red) types a chat message containing <Empty String> as A substring
07-18-2006, 05:27 AM#4
harshateja
Your if statement makes absolutely no sense. You are basically saying if a == a +1 which can never be true. Instead take out the if statement and make your event:

Trigger:
Player - Player 1 (Red) types a chat message containing -level as A substring

Then change your conversions from string to integer to get the level to substring(6,Length(EnteredChatString).
07-18-2006, 05:49 AM#5
Hemlock
the only way why the event looks like this is cause I don't want to make a dozen triggers for all chat commands there are available, so I used empty string and then check the strings with variables.

I do not exactly understand your explanation however
07-18-2006, 06:27 AM#6
SentryIII
You don't have to make a trigger for each player for each command. Just put 12 events for each trigger, 1 event for each player.

Also noticed this if statement from harshateja's post:

Trigger:
(Entered chat string) Equal to (-level + (String((Integer((Entered chat string))))))

For example, if you type "-level 5" this will check the following:

"-level 5" Equal to "-level 0"

What's happening is you're trying to convert the string "-level 5" into an integer. Since you have non-numeric characters in that string, it will return 0. Therefore, that if statement will always return false.

Simply change that conversion to the following:

Quote:
Originally Posted by harshateja
Then change your conversions from string to integer to get the level to substring(6,Length(EnteredChatString).
07-18-2006, 08:37 AM#7
Fireeye
You can also make all in one Trigger, i'll show you.
What you have to do, store your hero in a Variable with Array, that means, the hero of Player 1 in Hero[1], the hero of Player 2 in hero[2], etc.

Trigger:
Collapse Events
Player - Player 1 (Red) types a chat message containing -level as A substring
Player - Player 2 (Blue) types a chat message containing -level as A substring
Player - Player 3 (Teal) types a chat message containing -level as A substring
Conditions
Actions
Collapse If - (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Integer((Substring), 8, (Lenght of (Entered Chat String))))) less than or equal to (Hero level of Hero[(Player Number of (Triggering Player))]
Collapse Then - Actions
Game - Display to (Player group((Triggering Player))) for 0.25 seconds the text: Error
Collapse Else - Actions
Hero - Set Hero[(Player Number of (Triggering Player))] Hero-level to (Integer((substring), 8, (Lenght of (Entered Chat String))))), Show level-up graphics
Game - Display to (Player group((Triggering Player))) for 0.25 seconds the text: Successful level up
07-18-2006, 09:55 AM#8
oNdizZ
what he wants is one trigger for all commands. not just one trigger per command. thats why he used that event
Trigger:
Player - Player 1 (Red) types a chat message containing <Empty String> as A substring

just change your first If - Condition to:
Trigger:
(Substring((Entered chat string), 1, 6)) Equal to -level

and your second one to Fireeye's condition.
07-18-2006, 10:03 AM#9
Whitehorn
How about a substring of '-' ?
07-18-2006, 10:08 AM#10
oNdizZ
ye, i guess that would be a little better if all the commands starts with a "-" which they usually do. Dunno if it will help much to the map though since you usually dont spamm constanly with a 0.01 interval in a game. Not that "that" would do anything anyways.
07-18-2006, 11:20 AM#11
Hemlock
all commands start with - so I could use that as a substring.
I only need to display it to 1 player so thats easier as well.

no do I not really get the "Substring((Entered chat string), 1, 6" what does the action do preciously?\\

P.S the hero is able to level up till 15
07-18-2006, 11:22 AM#12
Whitehorn
It creates a substring from the entered chat string starting at a, ending at b.
07-18-2006, 11:57 AM#13
Hemlock
Quote:
Originally Posted by Whitehorn
It creates a substring from the entered chat string starting at a, ending at b.

But how does that detect my integer value in this case?
07-18-2006, 01:44 PM#14
iNfraNe
that one doesnt, 1 to 6 checks for, obvious the first six chars on the string, being "-level" in this case. To check the int just do String 2 Integer (Substring(Entered Chat message, 8, 8)) (not 7 because there's a space between).
07-18-2006, 03:30 PM#15
The)TideHunter(
Fireeye's trigger is fine, it will work good.

A substring is just a part of a string cut up.

Example:

Word = fish, Min = 2, Max = 3, output = is
Letter 2 to letter 3 = is.

Word = Hello People, Min = 7, Max = 9, output = Peo

A space is also a character (duh!).

So Fireeye checked if the substring past the word -level was higher than the current level, and if it is set it.

Code:
123456789
-level 5

He checks if 1234567 is = to "-level " (Notice the space), and sets the level to Substring - Min = 7, Max = stringlength, so its to the end.

His method will work without flaws.