Jump to content




Change Colour of full Line


  • You cannot reply to this topic
5 replies to this topic

#1 Wilma456

  • Members
  • 187 posts
  • LocationGermany

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


#2 Sewbacca

  • Members
  • 450 posts
  • LocationStar 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?

#3 Wilma456

  • Members
  • 187 posts
  • LocationGermany

Posted 13 November 2016 - 04:35 PM

I mean this

#4 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited 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


#5 Wilma456

  • Members
  • 187 posts
  • LocationGermany

Posted 13 November 2016 - 05:52 PM

View PostKingofGamesYami, on 13 November 2016 - 04:58 PM, said:

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.

#6 Sewbacca

  • Members
  • 450 posts
  • LocationStar Wars

Posted 13 November 2016 - 06:09 PM

You have to set the cursor position before





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users