Requires a bit of effort, but can be done.
function wrapText(text, limit)
local lines = {}
local curLine = ''
for word in text:gmatch('%S+%s*') do
curLine = curLine .. word
if #curLine + #word >= limit then
lines[#lines + 1] = curLine
curLine = ''
end
end
return lines
end
This basically searches through each grouping of nonspace characters and space characters (a word, basically), then adds to the current line in the loop. If the length of the line is greater than the limit given, throw the current line in our table of wrapped lines, and clear the current line.
After using this function, all you need to do is write the given lines manually to the screen.
Example:
local text = 'some really really really long text that needs to be wrapped severely'
local wrapped = wrapText(text, 15)
print(table.concat(wrapped, '\n'))