Multiline text
Hot to make a multiline text for screen.drawText?
I try a real new line, but this returns error (in JS project)
I also try "\r", "\n" & "\r\n" - no result!
Maybe here some special symbol hidden somethere?
Hot to make a multiline text for screen.drawText?
I try a real new line, but this returns error (in JS project)
I also try "\r", "\n" & "\r\n" - no result!
Maybe here some special symbol hidden somethere?
Could not figure it out either, so I use this:
https://microstudio.dev/i/Martellus/llfcdrawtextex/
Nothing fancy yet, but it fit what I needed at the time.
Code for the left justified func, which is what I use the most - see project for center and right justified:
llfcDrawTextExLeft = function(txt,x=0,y=0,tsize=8,tcolor="#FFF",crlf="|n")
// draws only LEFT Justified from X for now
// for now, using | instead of backslash cause of weird artifacts I had with backslash.
// does not yet support escaping |
if not txt or txt.length < 1 then return end
local textArr = 0
if txt.length > crlf.length then
textArr = txt.split(crlf)
else
textArr.push(txt.replace(crlf,""))
end
local numLines = textArr.length
local lx = x
local ly = y+((numLines/2)*tsize)-(tsize*.5)
for t in textArr
lx = x + screen.textWidth(t,tsize)/2
screen.drawText(t,lx,ly,tsize,tcolor)
ly -= tsize
end
end
Cheers!
Thanks, @Martellus
But i wounder - is there any chance to make multiline text within one .drawText?