
*here we see a if statement with an else on it that is controled from the variable a. Another thing, if statements are used to check a status of a variable or function and act based on that observation.

Ok now that we know the basics of lua within computercraft, lets get into if statements and some rednet!įirst of all rednet is used as a in game wifi, for multiple turtles and computers to use as communication from one another. The end command is also used for other loops and if-else statements too. *The end command is for ending the loop (knowing where to repeat again). A string is a collection of characters in one variable. The variable name for a sentence is called a string. *The print command is really simple! It just prints what ever you type in it! But make sure to have quotation marks around the sentence or else it won't work. Think of the sleep command as a redstone repeater, it delays the redstone and keeps it going! The 0.1 within the ( ) is how long the delay. *the sleep command is key for a loop, especially the infinite loop! the sleep command is used as a delay device as also a checkup command for huge loops. If you had a variable instead of the true statement, the loop could end and move on to the rest of the code. In this case there is no variable, instead it is just true (between the while and do), meaning that the loop will go on forever.
#Cool turtle programs computercraft code#
First of all loops are made to run the code within the loop (starting at while and ending at end) in till a variable is false. *Here we see a while loop with a print command and a sleep command. Since this has an infinite loop, you might have to hold down the control key and r to restart the computer. To execute the program you just type in the filename (nothing else) and press enter to see it run. *when you are done with the code, press control key, select save then repeat but select exit instead. *To have a program say hello world over and over again you can type this in: For this tutorial I prefer you do not name the file startup. *First to create a file you must type in edit then that file will be created and a blank screen is presented to you. We will start off with the basic structure of what the code looks like (which the programming language is lua).


Ok then, in order to program on a computer in minecraft you must have a certain understanding of logic, with if statements, loops, etc. I figure I would do a short yet effective tutorial on the minecraft forums. Anyways I figure out most of the api and started to do tutorials and all of that fun stuff What appeared to me one of the most fun, were the computers and turtles from the computercraft mod. it changed my whole way of doing things in minecraft.
#Cool turtle programs computercraft mod#
I am a huge redstone person and ever since I got hold of the technic/tekkit mod bundle pack. Hello everyone! I have been trying to figure out where to exactly post this, but I figured this would be a good place to post it. Ok so I was told to post this topic in this part of the forums from the previous place I posted the topic.
