This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Wilma456's profile picture

Change Colour of full Line

Started by Wilma456, 13 November 2016 - 01:54 PM
Wilma456 #1
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
Sewbacca #2
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?
Wilma456 #3
Posted 13 November 2016 - 04:35 PM
I mean this
KingofGamesYami #4
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
Wilma456 #5
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.
Sewbacca #6
Posted 13 November 2016 - 06:09 PM
You have to set the cursor position before