term.clearLine
term.clearLine Function | |
---|---|
Syntax term.clearLine() | |
Returns | nil |
API | term |
Source | CC:Tweaked (source) |
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.
|
|||
Writes a line, waits, and then clears it. | |||
Code | write("Hello, world!")
term.clearLine()
|
||
Output | Hello, world! is printed, and then disappears after 1 second. |
|
|||
Clears the top line of the current term with a red colour. | |||
Code | term.setBackgroundColour(colours.red)
term.setCursorPos(1, 1)
term.clearLine()
|
||
Output | The top line of the screen is cleared and filled with red. |
|
|||
Draws a line which each colour to the screen, clearing everything between. | |||
Code | 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 [[Colours]] 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
|
||
Output | ![]() |