Jump to content




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


  • You cannot reply to this topic
2 replies to this topic

#1 LeDark Lua

  • Members
  • 369 posts
  • LocationLeLua

Posted 17 September 2015 - 01: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 by LeDark Lua, 17 September 2015 - 01:33 PM.


#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 17 September 2015 - 01: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.

#3 LeDark Lua

  • Members
  • 369 posts
  • LocationLeLua

Posted 17 September 2015 - 01:38 PM

Oh ok, thank you. Its fixed now :D





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users