ZizZazZuz
|
  |
| Joined: 16 Jun 2008 |
| Total Posts: 2743 |
|
|
| 28 Mar 2012 08:01 PM |
| Using a Gui, how can you tell how many lines a TextLabel uses? |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2012 08:11 PM |
| Not sure. Don't think there's an easy way. Maybe there's another way to do what you want? |
|
|
| Report Abuse |
|
|
ZizZazZuz
|
  |
| Joined: 16 Jun 2008 |
| Total Posts: 2743 |
|
|
| 29 Mar 2012 10:53 AM |
Well that sucks... OK, how about this, how can I get each letter in a TextLabel?
e.g.:
This is a string
How would I go through and get every letter? And, say I have another string with every letter of the alphabet. Could I match the two letters? |
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 29 Mar 2012 11:20 AM |
Like a string.gmatch loop?
for let in string.gmatch(string,".") do --Each character, besides spaces. end
So..
t = "This is a string." for let in string.gmatch(t,".") do print(let) end
>T >h >i >s >i >s >a >s >t >r >i >n >g >. |
|
|
| Report Abuse |
|
|
ZizZazZuz
|
  |
| Joined: 16 Jun 2008 |
| Total Posts: 2743 |
|
|
| 29 Mar 2012 04:02 PM |
So, say I had an encoded alphabet, say,
alpha = "antidsetblhmnrcfghjkopqruvwxyz" alphaN = "abcdefghijklmnopqrstuvwxyz"
Would this encode it to that alphabet?
t = "this is a string." for let in string.gmatch(t,".") do for code in string.gmatch(alphaN, ".") do if code == let then
end
Oh wait... Can I get the number of the character in a string? E.g., the fourth character in t is 's'. |
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 29 Mar 2012 04:05 PM |
t = "Whatever" z = 0 for let in string.gmatch(t,".") do z=z+1 --etc |
|
|
| Report Abuse |
|
|
ZizZazZuz
|
  |
| Joined: 16 Jun 2008 |
| Total Posts: 2743 |
|
|
| 29 Mar 2012 04:22 PM |
alpha = "antidsetblhmnrcfghjkopqruvwxyz" alphaN = "abcdefghijklmnopqrstuvwxyz"
t = "this is a string."
for let in string.gmatch(t,".") do match = false cLet = 0 oriLet = 0
for code in string.gmatch(alpha, "%a") do cLet = cLet + 1 if code == let then match = true
for ori in string.gmatch(alphaN, "%a") do oriLet = oriLet + 1 if oriLet == cLet then if newString == nil then newString = ori else newString = newString.. ori end end end end end
if not match then if newString == nil then newString = let else newString = newString.. let end end end
Would THAT encode it? I don't have studio at the moment. Oh, and would it keep spaces? |
|
|
| Report Abuse |
|
|
3lex33
|
  |
| Joined: 08 Oct 2008 |
| Total Posts: 5220 |
|
|
| 29 Mar 2012 04:24 PM |
| What do you mean by encode? What exactly do you want to do, as it is unclear to me. Can you give example? |
|
|
| Report Abuse |
|
|
ZizZazZuz
|
  |
| Joined: 16 Jun 2008 |
| Total Posts: 2743 |
|
|
| 29 Mar 2012 04:28 PM |
| It would just change around the letters in string t. |
|
|
| Report Abuse |
|
|
ZizZazZuz
|
  |
| Joined: 16 Jun 2008 |
| Total Posts: 2743 |
|
|
| 29 Mar 2012 06:28 PM |
it works, except it doesn't do W and V, capital and lowercase. I expect it doesn't do U, X, Y, and Z either.
alpha = "aAnNtTiIdDsSeEtTbBlLhHmMnNrRcCfFgGhHjJkKoOpPqQrRuzZxXwWvVyYuU" alphaN = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ"
t = "This is the normal/origional scentance. Below is the encoded version."
for let in string.gmatch(t,".") do match = false cLet = 0 oriLet = 0
for code in string.gmatch(alpha, "%w") do cLet = cLet + 1 if code == let then match = true
for ori in string.gmatch(alphaN, "%w") do oriLet = oriLet + 1 if oriLet == cLet then if newString == nil then newString = ori else newString = newString.. ori end end end end end
if not match then if newString == nil then newString = let else newString = newString.. let end end end
print(t) print(newString)
for let in string.gmatch(newString,".") do match = false cLet = 0 oriLet = 0
for code in string.gmatch(alphaN, "%w") do cLet = cLet + 1 if code == let then match = true
for ori in string.gmatch(alpha, "%w") do oriLet = oriLet + 1 if oriLet == cLet then if String == nil then String = ori else String = String.. ori end end end end end
if not match then if String == nil then String = let else String = String.. let end end end print("Decoded") print(String) print(alpha) print(alphaN) |
|
|
| Report Abuse |
|
|
ZizZazZuz
|
  |
| Joined: 16 Jun 2008 |
| Total Posts: 2743 |
|
|
| 29 Mar 2012 06:36 PM |
Edited for certainty.
alpha = "aAnNtTiIdDsSeEtTbBlLhHmMnNrRcCfFgGhHjJkKoOpPqQrRuzZxXwWvVyYuU" alphaN = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ"
t = "This is the normal/origional sentence. Below is the encoded version. uU vV wW xX yY zZ."
for let in string.gmatch(t,".") do match = false cLet = 0 oriLet = 0
for code in string.gmatch(alpha, "%w") do cLet = cLet + 1 if code == let then match = true
for ori in string.gmatch(alphaN, "%w") do oriLet = oriLet + 1 if oriLet == cLet then if newString == nil then newString = ori else newString = newString.. ori end end end end end
if not match then if newString == nil then newString = let else newString = newString.. let end end end
print(t) print(newString)
for let in string.gmatch(newString,".") do match = false cLet = 0 oriLet = 0
for code in string.gmatch(alphaN, "%w") do cLet = cLet + 1 if code == let then match = true
for ori in string.gmatch(alpha, "%w") do oriLet = oriLet + 1 if oriLet == cLet then if String == nil then String = ori else String = String.. ori end end end end end
if not match then if String == nil then String = let else String = String.. let end end end print("Decoded") print(String) print(alpha) print(alphaN)
h = Instance.new("Hint", workspace) h.Text = t wait(3) h.Text = newString wait(3) h.Text = String |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2012 07:03 PM |
Cant you just check for \n?
local lines = 1 for s,k in TEXT:gmatch("\n") do lines = (lines+1) end
print("Text has " .. tostring(lines) .. " lines") |
|
|
| Report Abuse |
|
|
ZizZazZuz
|
  |
| Joined: 16 Jun 2008 |
| Total Posts: 2743 |
|
|
| 29 Mar 2012 07:09 PM |
| I don't know if TextLabels work that way. I guess I could try. Btw, fixed encoder/decoder. |
|
|
| Report Abuse |
|
|