# TutorialString Manipulation Tutorial

#### hell_knight

##### Playing WoW
String Manipulation Tutorial
By hell_knight99

Starting Off

String Maniupulation is very simple as soon as you understand how to work it. After you get started its straight forward and simple. With practice you can easily perfect the skill of String Manipulation. Some notes.
1. Pay attention that spaces do count in string length
2. Ex, -level 99 is 9 letters long.
3. You must know how to count.
4. All entered chat strings must be sub string.

The Basics

Time to start off with the basics. First you need an idea of something you want to do, whether it be a command giving gold, changing level, or changing a players name. I will give a trigger which you can examine and study. Then i will explain how it works.

Level up
Events
Player - Player 1 (Red) types a chat message containing -level as A substring
Conditions
(Length of (Entered chat string)) Equal to 9 Hmm -level and a space is only 7 letters long why is this set to 9?
Actions
Hero - Set Blood Mage 0000 <gen> Hero-level to (Integer((Substring((Entered chat string), 8, 9)))), Hide level-up graphics What is this giberish?

_________________________________________________________________

Hero - Set Blood Mage 0000 <gen> Hero-level to (Integer((Substring((Entered chat string), 8, 9)))), Hide level-up graphics is what I think the most vital part of this trigger. First of all I go to Hero set level-blood mage , then his hero level is to go to? Press Convert String to Interger, Substring, Entered Chat String. Now W.E knows your talking about that string.

Second it needs to know what part of it to convert, for the first number is where it starts converting, so lets put letter 8, which happens to be the first number, then 9 meaning the second number. It is then converted to a number.

-level 10 will give you a level 10 hero, but -level 1 wont! But -level 01 works. Why??

This trigger is very basic and thats one of its flaw is can be fixed which is more advanced and will be discussed later. But the alternate way is to type -level 0 then the one digit number.

_________________________________________________________________

Name Changing

Ahh who doesn't love this one. It allows you to change a players name.
Now I will teach you how to do this one.Like the last I will show you the trigger then explain it to you.

Name Change
Events
Player - Player 1 (Red) types a chat message containing -name as A substring
Conditions No Condition Needed
Actions
Player - Set name of (Triggering player) to (Substring((Entered chat string), 7, (Length of (Entered chat string)))) Almost the same thing

_________________________________________________________________

Almost the same thing heh? Player - Set name of (Triggering player) to (Substring((Entered chat string), 7, (Length of (Entered chat string)))) So we make the message we want. We still need to count though. Player- Set Name- to Substring >> Entered Chat String >> The length of your chat string+ the space + 1 , Then for the second number go to String Length, Entered Chat String. So it sets the players name from letter 7 to the end of the chat string. Not too hard ehh>?

_________________________________________________________________

The Finals

Wow it seemed so short don't you think. Once you understand string manipulation is very simple. Now to put your skills to one final test. Remember the basics? Now to teach how to change it so that the first one works like -level 1 or like -level 10. Just like the last 2 trigger, examination,study, explantion,practice.

Level up Copy
Events
Player - Player 1 (Red) types a chat message containing -level as A substring
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Length of (Entered chat string)) Equal to 9
Then - Actions
Hero - Set Blood Mage 0000 <gen> Hero-level to (Integer((Substring((Entered chat string), 8, 9)))), Hide level-up graphics
Else - Actions
Do nothing
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Length of (Entered chat string)) Equal to 8
Then - Actions
Hero - Set Blood Mage 0000 <gen> Hero-level to (Integer((Substring((Entered chat string), 8, 8)))), Hide level-up graphics
Else - Actions
Do nothing
_________________________________________________________________

Theres no difference if you brake it up. First of all there is no longer a condition. So we put a If/All/Cond True, if its equal to 9 string length then repeat exactly what you did in the basics. NOW the different part is copy and paste now. Change (Length of (Entered chat string)) Equal to 9 to (Length of (Entered chat string)) Equal to 8 then change the hero set levle bloodmage substring,blahblah to 8,8 instead of 8,9. Disable your first The Basics trigger. Now test it if you did it right it should work.

Finishing Credits

This is my first Tutorial Ever.Please take it easy on me I am considering screenshots but string manipulation doesn't really show anything but success which teaches nothing.

Please Give Reputation if you found this useful

#### Miz

Well it seem 3.5 stars it could use pictures
but
could you tell me how when a person types in a chat message like so

Code:
``````         [COLOR="DeepSkyBlue"]Event[/COLOR]
[COLOR="Red"]Player[/COLOR] - Player 1 (Red) types a chat message containing [COLOR="Lime"]-name ruler[/COLOR] as An exact match``````

could you make it so there name become what they type
so it would now it will be ruler :shades:
can you help me

#### Tom Jones

##### N/A
Code:
``````Untitled Trigger 001
Events
Player - Player 1 (Red) types a chat message containing <Empty String> as An exact match
Conditions
Actions
Player - Set name of Player 1 (Red) to (Entered chat string)``````
Your using the worng event The substring event would mean that i could type: "123-level". So the event triggers and condition triggers, even though the string is wrong. You should use this instead:
Code:
``````Untitled Trigger 001
Events
Player - Player 1 (Red) types a chat message containing <Empty String> as An exact match
Conditions
(Entered chat string) Equal to whatever
Actions``````
Using the stringlength as condition is simply not good enough.

#### Sooda

##### Diversity enchants
Please Give Reputation if you found this useful
Add code tags to GUI actions. Creating a Rep Farm is just lame... people will keep you in mind if they find it really useful.

#### Tom Jones

##### N/A
I agree with Sooda. For me it seems like you didn't even investigate other options, even though they might be better (they are!). You just used the one you knew! A reminder for further tutorials:
When you make a tutorial you should have proper knowlegde on the subject to teach others the entire subject, even though your tutorial only covers some part of the subject.
Please Give Reputation if you found this useful
Nobody should find this usefull...

#### Chocobo

##### White-Flower
PHP:
``[code][/code]``

CODE tags.

Finishing Credits

This is my first Tutorial Ever.Please take it easy on me I am considering screenshots but string manipulation doesn't really show anything but success which teaches nothing.

Please Give Reputation if you found this useful

Too big.
This thread seems only to attract rep for you if you see what we've said. It shouldn't be there.

Level up Copy
Events
Player - Player 1 (Red) types a chat message containing -level as A substring
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Length of (Entered chat string)) Equal to 9
Then - Actions
Hero - Set Blood Mage 0000 <gen> Hero-level to (Integer((Substring((Entered chat string), 8, 9)))), Hide level-up graphics
Else - Actions
Do nothing
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Length of (Entered chat string)) Equal to 8
Then - Actions
Hero - Set Blood Mage 0000 <gen> Hero-level to (Integer((Substring((Entered chat string), 8, 8)))), Hide level-up graphics
Else - Actions
Do nothing

Can be done in 1 line of action and 1 line of of condition.

Name Change
Events
Player - Player 1 (Red) types a chat message containing -name as A substring
Conditions No Condition Needed
Actions
Player - Set name of (Triggering player) to (Substring((Entered chat string), 7, (Length of (Entered chat string)))) Almost the same thing

7,20. 14 max letters.

1. Pay attention that spaces do count in string length
2. Ex, -level 99 is 9 letters long.
3. You must know how to count.
4. All entered chat strings must be sub string.

Nope.

Just to let know : if no Conditions, what happens when we write : blabla -name ?

^^

General chit-chat
Help Users
• No one is chatting at the moment.