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

HELP: text=text:sub(count, #text)

Started by LeDark Lua, 17 September 2015 - 12:28 PM
LeDark Lua #1
Posted 17 September 2015 - 02:28 PM
My problem is this:

while x+(self.x-1) < self.x do
if #text<1 then
  break
else
  startCount=startCount+1
  x=x+1
  text=text:sub(startCount, #text)
end
end

This will cut out 1, 3, … characters and I don't know why.

I want to get this effect:

Text
ext
xt
t
Edited on 17 September 2015 - 12:33 PM
Lyqyd #2
Posted 17 September 2015 - 02:35 PM
It's doing exactly what you tell it to.

When the value is 2, it cuts off the first character, so the string contains "ext". Then the value is changed to 3, so it cuts off the first two characters of "ext", leaving you with "t".

You want to either always start at position 2, or always take your substring from the original variable, not the shortened string.
LeDark Lua #3
Posted 17 September 2015 - 02:38 PM
Oh ok, thank you. Its fixed now :D/>