This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
LeDark Lua's profile picture

Sentence/Text/Word to chars.

Started by LeDark Lua, 30 July 2015 - 10:46 AM
LeDark Lua #1
Posted 30 July 2015 - 12:46 PM
So i have this text:
This is an awesome text.
And I want it to change into:
Spoiler

T
h
i
s

i
s

a
n

a
w
e
s
o
m
e

t
e
x
t
.

Thanks in advance.
Edited on 30 July 2015 - 10:50 AM
Lignum #2
Posted 30 July 2015 - 01:08 PM
You could do this:

local str = "Test"
local chars = {}

for i=1,#str do
   chars[#chars + 1] = str:sub(i, i)
end

return chars

To reverse it, use table.concat:

return table.concat(chars)
LeDark Lua #3
Posted 30 July 2015 - 01:10 PM
Thanks.