Difference between revisions of "Clear"

From ComputerCraft Wiki
Jump to: navigation, search
m (Forgot to sign off, oops!)
(shell.run("clear") shouldn't even be hinted at.)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{ToDelete|This contains information already available on the [[CraftOS Shell]] page. - [[User:Oeed|Oeed]] 07:52, 26 March 2014 (GMT)}}
+
'''Clear''' is a built-in [[CraftOS_Shell|shell script]] for use within ComputerCraft. Running it wipes the current display and moves the cursor to the top left position.
  
== Clear ==
+
The equivalent code (for use within your own scripts) would be:
  
Clear is a built-in program in ComputerCraft.
+
[[term.setBackgroundColor]]([[Colors (API)#Colors|colours.black]])  -- Set the background colour to black.
You may want to use it in a script like:
+
[[term.clear]]()                            -- Paint the entire display with the current background colour.
<pre>
+
[[term.setCursorPos]](1,1)                  -- Move the cursor to the top left position.
  shell.run('clear')
+
  print('Your screen has been cleared!')
+
</pre>
+
or just type:
+
<pre>
+
clear
+
</pre>
+
in the computer.
+
<br />
+
This clears the screen so you can write text.
+
<br />
+
'''NOTE: It is not recommended to use the above code in a program, instead use [[Term.clear]]. It is only recommended to use this program to clear the screen through the shell.'''
+
== term.clear ==
+
For term.clear, visit [[Term.clear]]
+
  
[[Category:Programs]][[Category:Tutorials]]
+
[[Category:Programs]]

Latest revision as of 02:58, 25 June 2014

Clear is a built-in shell script for use within ComputerCraft. Running it wipes the current display and moves the cursor to the top left position.

The equivalent code (for use within your own scripts) would be:

term.setBackgroundColor(colours.black)  -- Set the background colour to black.
term.clear()                            -- Paint the entire display with the current background colour.
term.setCursorPos(1,1)                  -- Move the cursor to the top left position.