Difference between revisions of "Creating a simple name reading program"

From ComputerCraft Wiki
Jump to: navigation, search
(Created page with "This Will Be A Tutorial On Making A Program That Will Read A Name. This is the code. print("Enter Your Name:") name = read() print("Hello "..name..", Thats A Cool Na...")
 
(Removed from Programs category)
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
This Will Be A Tutorial On Making A Program That Will Read A Name.
+
== The Code ==
This is the code.
+
This will be a tutorial on making a program that will read a name.
 +
This is the code:
 +
<pre>
 +
  print("Enter Your Name: ")
 +
  local name = read()
 +
  print("Hello "..name..", that's a cool name.")
 +
</pre>
 +
The print is pretty obvious, it puts the text on the screen and makes a new line.
 +
Now the 'local name = read()' sets 'name' as a variable which contains a string (piece of text) which the user typed, in this case it's his/her name.
 +
And the last line will print some text, and the '"..name.."' concatenates (merges) the text before it with the text that the variable 'name' contains.
  
  print("Enter Your Name:")
+
This is another version for my door:
  name = read()
+
<pre>
  print("Hello "..name..", Thats A Cool Name")
+
   textutils.slowPrint("Enter Your Name: ")
 
+
   local name = read()
The print is pretty obvious, it puts the text there and starts a new line.
+
   print("Okay "..name..", door's open!")
Now the 'name = read()' sets 'name' as a variable or in othe words what it reads and calls it.
+
   rs.setOutput("right",true) -- this can be changed, "right" is the side of door / redstone
And the last line will print some text and the '"..name.."' uses the variable 'name' and puts it in the print
+
 
+
This Is Another Version For My Door
+
 
+
   textutils.slowPrint("Enter Your Name:")
+
   name = read()
+
   print("Okay "..name.." Door's Open")
+
   rs.setOutput("right",true) -- this can be changed
+
 
   sleep(5)
 
   sleep(5)
   os.shutdown
+
   os.shutdown()
 +
</pre>
  
Please Do Not Edit This Or Claim To Be Your Own This Belongs To Jadengregory00(minecraft username)
+
[[Category:Tutorials]]

Latest revision as of 07:43, 26 March 2014

The Code

This will be a tutorial on making a program that will read a name. This is the code:

   print("Enter Your Name: ")
   local name = read()
   print("Hello "..name..", that's a cool name.")

The print is pretty obvious, it puts the text on the screen and makes a new line. Now the 'local name = read()' sets 'name' as a variable which contains a string (piece of text) which the user typed, in this case it's his/her name. And the last line will print some text, and the '"..name.."' concatenates (merges) the text before it with the text that the variable 'name' contains.

This is another version for my door:

   textutils.slowPrint("Enter Your Name: ")
   local name = read()
   print("Okay "..name..", door's open!")
   rs.setOutput("right",true) -- this can be changed, "right" is the side of door / redstone
   sleep(5)
   os.shutdown()