term.clearLine

Clears the line on a terminal object using the current Y cursor position and background colour. The term's cursor position, text colour and background colour states remain unchanged.

ExampleClear a line
Writes a line, waits, and then clears it.
Code
<nowiki>
write("Hello, world!")
term.clearLine()
  </nowiki>
Output Hello, world! is printed, and then disappears after 1 second.
ExampleClear a specific line with a colour
Clears the top line of the current term with a red colour.
Code
<nowiki>
term.setBackgroundColour(colours.red)
term.setCursorPos(1, 1)
term.clearLine()
  </nowiki>
Output The top line of the screen is cleared and filled with red.
ExampleClear many lines with different colours
Draws a line which each colour to the screen, clearing everything between.
Code
<nowiki>
for i = 1, 16 do -- There are 16 colours.
  -- Colours in CC are a bitfield, so raising two to the power of n will give the nth colour.
  -- See </nowiki>[[Colours]]<nowiki> for more information.
  local colour = math.pow(2, i - 1) -- Subtract 1 as colours start from 0
  term.setBackgroundColour(colour)
  term.setCursorPos(1, i)
  term.clearLine()
end
  </nowiki>
Output

term.clearLine
Function
Syntax
term.clearLine()
Returns nil
API term
Source CC:Tweaked (source)
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.