Posted 01 September 2014 - 04:37 AM
I've got a function that breaks a string down into 'lines', so I can fit it into a defined space. However, I'm having trouble with the spaces:
Below does not have the offset, however none of the words are spaced. (edit: actually, the first line is spaced. The rest are not)
It could be the fact that I'm using mimic, however I have not run into any similar issues with it.
Additionally, the code I use to render it is here, if that makes any difference:
--#note: minx/maxx/miny/maxy are coords defining the space
local lines = { [1]=""}
for word in text:gmatch( "%S+" ) do
local oldLine = lines[ #lines ]
lines[ #lines ] = lines[ #lines ] .. " " .. word
if #lines[ #lines ] > maxx - minx then
lines[ #lines ] = oldLine
lines[ #lines + 1 ] = word
end
end
The above works, however the first line is offset by one space…Below does not have the offset, however none of the words are spaced. (edit: actually, the first line is spaced. The rest are not)
local lines = { [1]=""}
for word in text:gmatch( "%S+" ) do
local oldLine = lines[ #lines ]
lines[ #lines ] = lines[ #lines ] .. word .. " "
if #lines[ #lines ] > maxx - minx then
lines[ #lines ] = oldLine
lines[ #lines + 1 ] = word
end
end
It could be the fact that I'm using mimic, however I have not run into any similar issues with it.
Additionally, the code I use to render it is here, if that makes any difference:
local l = self.miny
for _, line in ipairs( self.lines ) do
term.setCursorPos( self.minx, l )
term.write( line )
l = l + 1
end
Edited on 01 September 2014 - 02:40 AM