188 posts
Location
Germany
Posted 13 November 2016 - 02:54 PM
How can I change the Colour of a full Line? I had ever used this code, but its very slow.
function setLineColor(text)
local lccou = string.len(text)
write(text)
local looplc = true
while looplc == true do
write(" ")
lccou = lccou + 1
if lccou == 51 then
looplc = nil
lccou = nil
end
end
print("")
end
463 posts
Location
Star Wars
Posted 13 November 2016 - 03:18 PM
What do you want to achieve?
A empty line with a specific color?
function setLineColor(y, col)
term.setCursorPos(1, y)
term.setBackgroundColor(col)
term.clearLine()
end
Or an empty line form x1 to x2?
function setLineColor(x1, x2, y, col)
paintutils.drawFilledBox(x1, y, x2, y, col)
end
Or what do you mean?
188 posts
Location
Germany
Posted 13 November 2016 - 04:35 PM
3057 posts
Location
United States of America
Posted 13 November 2016 - 04:58 PM
Just attach some spaces to the end of the text so that it writes to the edge of the screen. Something like this:
function writelineInColor( text, color )
term.setBackgroundColor( color )
term.write( text .. string.rep( ' ', term.getSize() - #text ) )
end
188 posts
Location
Germany
Posted 13 November 2016 - 05:52 PM
Just attach some spaces to the end of the text so that it writes to the edge of the screen. Something like this:
function writelineInColor( text, color )
term.setBackgroundColor( color )
term.write( text .. string.rep( ' ', term.getSize() - #text ) )
end
I had tested this in Mynaptic: This code only overitete line 2. Any other line is not suportet.
463 posts
Location
Star Wars
Posted 13 November 2016 - 06:09 PM
You have to set the cursor position before