ComputerCraft. So, what is it?

 Like I described in my first post I said I was programming in Minecraft using a mod called ComputerCraft. And that statement is not completely correct. 

What I am actually doing is coding outside of Minecraft and running this code in Minecraft of the turtles from ComputerCraft. 

A basic turtle from ComputerCraft


So what is ComputerCraft?

Well TL;DR it's a mod that adds some items into Minecraft like computers, floppy disks and turtles. With these items anyone could write/use programs on them. 

The proper explanation from the ComputerCraft wiki goes as follows:
ComputerCraft is a mod created for Minecraft by dan200 that adds Computers, Monitors, Modems, Turtles and more! ComputerCraft's Computers and Turtles are programmed with the easy-to-learn Lua programming language. You can use Redstone, RedPower or even MineFactory Reloaded alongside with your devices for the best experience.

That's it! It's pretty cool and has been around for quite some time now. I remember seeing it on some Minecraft Let's Play's when I was younger and always wanted to do something with it myself but was too intimidated by having to program myself. However, now that I have grown up a bit I realized that programming isn't that scary or hard and decided I might as well give it a go. 

So far I have written a little bit and that will be discussed a little further. Let's first go over the basics of the turtle itself. 

Basics of the turtle

 In this post I'll show how to move the turtle.
 

Movement of the turtle

For the turtle to move any direction it requires fuel. This can be from lava or coal (at least that are the 2 I know of). So if your turtle isn't moving check if maybe it doesn't have any fuel. 

A turtle can move in 4 directions. Forwards, backwards, upwards and downwards. These movements are based on which way the turtle is orientated. 

To make it so you can see what way the turtle is facing you can look for the little black bar that looks like a visor or a very long eyebrow.

The front/face of a turtle

Besides moving in a direction a turtle can also rotate. It can rotate to the left and to the right. Here is a little (hopefully not too confusing) reference of what the left(L), right(R), top(U), bottom(D), front(F) and back(B) of the turtle are.
Directions based on turtle face


It will become more clearer in a second. I promise. 

So let's now get into the nitty-gritty of the movement. 

First of forward moving. 

A turtle can move forward with the following code

turtle.forward()
   
A turtle moving forward

Moving backwards is

turtle.back()
 



A turtle moving back


Moving upwards is


turtle.up()





A turtle moving upwards


Last but not least downwards is


turtle.down()




A turtle moving downwards

That's most of the basic moving but we got 2 more important movements left. These are turning to the left and turning to the right. These are 

turtle.turnLeft()

 
 A turtle turning to the left


and 

turtle.turnRight()

A turtle turning to the right

That's most of the basic movement. The rest will be discussed in the next post. Stay tuned!

Comments

Popular posts from this blog

Design Guidelines. What, Why, How

Design principles, what and how.

I'm back!