Scripting Book/Chapter 5
Introduction
Hello!! In this chapter we will learn what a string is and learn how to manipulate one.
What is a string?
A string is something that holds text. In a script, to tell the script we are going to create a string, we write some text and put speechmarks around the text.
Where is it best used?
A string can be used to its full potential in StringValues, we will learn about values later. They can also be used in messages as we did earlier.
Where would I use it?
In the earlier chapters when we created messages and gave them text, they were strings.
m.Text = "Hello!" -- String m.Text = Hello! -- Not a string, will error Hello = "Hello!" -- String m.Text = Hello -- Variable redirecting to a string
What else is there to a string?
{ This part is UNFINISHED and you won't get the full educational value out of this submenu }
string.len
What does string.len do? string.len returns the amount of characters in a string.
soul = "Wuzzup Broski?" print(string.len(soul)) > 14
That prints 14 because there are 14 characters in the string 'Wuzzup Broski?'.
string.len can also be used in the form of a method.
soul = "Wuzzup Broski?" print(soul:len()) > 14
Instead of using string.len we can just put #STRING to return the length of the string.
soul = "Wuzzup Broski?" print(#soul) > 14
string.lower
What does string.lower do? string.lower makes all characters of the string lowercase.
p = "HELLO" print(string.lower(p)) > hello
string.upper
What does string.upper do? string.upper makes all characters of the string capitals.
p = "hello" print(string.upper(p)) > HELLO