|
| 25 Aug 2014 09:53 AM |
| Is there a way to get a number value of how many characters are in a string? |
|
|
| Report Abuse |
|
|
jaredmai
|
  |
| Joined: 08 Sep 2011 |
| Total Posts: 395 |
|
| |
|
|
| 25 Aug 2014 10:14 AM |
| How would I go about getting a "Typewriter" effect if I wanted to print something? But it has to change, because not everyone's playername is the same. |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 25 Aug 2014 10:16 AM |
#('String') string.len'String' ('String'):len()
If you want specifically how many LETTERS there are
local tab = {} for letter in gmatch('%a','letters') do table.insert(tab, letter) end
#tab is the amount of letters. |
|
|
| Report Abuse |
|
|
|
| 25 Aug 2014 11:23 AM |
#('String') string.len'String' ('String'):len()
What does that do? Can you dissect that for me? |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 25 Aug 2014 11:29 AM |
Strings are really similar to tables (maybe hard-coded as a list or something) so you can grab the length of a string with the length operator (#)
print(#('hello'))
-- Note, you can index strings if common sense didn't tell you that you could.
string.len is a function that gets length of strings.
print(string.len'hello')
('haidere'):len() is a bit different that all strings have an index that refers to "len" function like in string.len. Calling it like a method automatically makes the first argument itself which enacts like the previous example.
print(('haidere'):len())
|
|
|
| Report Abuse |
|
|