How to make self-writing dialogue?

I want the text to show in self-writing, like in Pokemon, Undertale, or any other game, but I have no idea of how to use the string functions to make it.

example:

texto = “hello”

“h”

“he”

“hel”

“hell”

“hello”

how can I do it?

s = [[this is a multiline

texto en lua]]

local tam = string.len(s)

local cantidad  = 0

local displayed = display.newText("", 100, 100)

–string.reverse(s)

timer.performWithDelay(50, function() cantidad = cantidad+1

 displayed.text = s:sub(tam-cantidad, tam) 

 end, tam)

–I tried this but the text is written from end to start, and not viceversa

You just need to make a slight adjustment. I would also recommend that you assign custom anchorX and Y to the text so that it functions like in those other games you mentioned.

 

s = [[this is a multiline texto en lua]] local tam = string.len(s) local cantidad = 0 local displayed = display.newText("", 100, 100) displayed.anchorX = 0 displayed.anchorY = 0 timer.performWithDelay(50, function() cantidad = cantidad+1 displayed.text = s:sub(1,cantidad) end, tam)

Thank you so much!!! :smiley:

s = [[this is a multiline

texto en lua]]

local tam = string.len(s)

local cantidad  = 0

local displayed = display.newText("", 100, 100)

–string.reverse(s)

timer.performWithDelay(50, function() cantidad = cantidad+1

 displayed.text = s:sub(tam-cantidad, tam) 

 end, tam)

–I tried this but the text is written from end to start, and not viceversa

You just need to make a slight adjustment. I would also recommend that you assign custom anchorX and Y to the text so that it functions like in those other games you mentioned.

 

s = [[this is a multiline texto en lua]] local tam = string.len(s) local cantidad = 0 local displayed = display.newText("", 100, 100) displayed.anchorX = 0 displayed.anchorY = 0 timer.performWithDelay(50, function() cantidad = cantidad+1 displayed.text = s:sub(1,cantidad) end, tam)

Thank you so much!!! :smiley: