Jump to content

ComputerCraft Mod - Turtles Tutorial


Recommended Posts

Turtles! How cute! [and deadly]

Turtles! Lovable, programmable... reptiles! No, no, no. Not those kind of turtles! These turtles :D



Prerequisite: If you're reading this, and you're not on the CraftersLand Server, you totally should check it out. Url is craftersland.net :) Since most of you will be playing on CraftersLand, you or your town Mayor/Assistant must allow them in your town. To do this, you must enter the following command:

/town perm town set ccturtles true

However, if you only want them in one chunk, which is probably the smarter choice, if you aren't doing turtles in every chunk of your town, the next command is better.

/town perm plot set ccturtles true

This will only allow them in one chunk of your town (the one you're standing in)


Turtles are the blocky robots that come with ComputerCraft! The Wiki for turtles on computercraft.info says:



Turtles and Advanced Turtles are essentially robots, and were added in the 1.3 update. They run an OS named TurtleOS, similar to CraftOS for Computers. They have the ability to place, break and detect blocks, move around and drop items in their inventory via their access to the Turtle API. The programs they run are stored in their internal memory, or on floppy disks.

Seeing as CraftOS and TurtleOS are very similar, I believe that the only main difference is that the TurtleOS startup shell is reskinned to say 'TurtleOS', and that the apis folder has one more api, this being the Turtle Api!


The turtle Api is an Api for Turtles Only that have many code-world interfaces, such as digging, placing, turning, moving, etc.


There are some functions that don't require a tool to dig, but it would be nice to have a compatible tool.

What I mean by this is that if you're using turtle.dig() to dig stone, you'll need a shovel turtle, and not a pickaxe one. So, this means that you must be specific with the type of job you want your turtle to do.


Premade Programs

There are some programs that come with the turtles. Feel free to play around with these! I have some creative descriptions to spark your imagination and creativity glands.

craft - this one requires a crafty turtle
dance - get on down with your bad self
excavate - holes, holes, digging the holes.
go - shoo, shoo, foul turtle.
refuel - get some coal in your system
tunnel - dig a tunnel for your mining laziness.
turn - you look around slowly, not sure what to think of your surroundings 



These are the only ones that I know of, but please tell me if I'm missing any x)



Using the turtle Api in your programs

 So, I'm going to teach you how the turtle Api works. It works like any other Api, in that it has functions, and return variables :). This being said, you can check out the Turtle Api page if you'd like and play around with it yourself, or you can follow the tutorial. If you're a beginner, I'd advise you stick to the tutorial for now :-).

First, We'll find a convenient location, such as the spot from my last tutorial :)). (img)

Next, we need to determine what we want our program to do. The program I have chosen to write is a simple square pattern. The Moves will be like this:

forward x3, left, forward x3, left, forward x3, left, forward x3, left

By using this pattern, the turtle will go in the square, and end up in the exact same spot as before, aswell as facing the same direction. An easy way to do this is by using for loops. These are easily manipulable to make them do whatever you want.

for i = 1,5 do
--will return
--1-5 on each newline.

We will use this condition loop to create a function so that we don't have to enter turtle.forward() 12 times.

function go(num)
  for i = 1,num do

Then, we will put the function together with the code to run it. Lets run it once.

function go(num)
  for i = 1,num do

--We are facing the original direction.

Optional: for extra fun add a while true do before the first go, and an end after the last turtle.turnLeft() for endless viewing fun & pleasure.

Some Self explanitory Functions

Some of these functions have up, down, left, and right variants, of which you can find on the Turtle Api page. The most self expanitory functions I didn't comment.

turtle.select(slotId) -- select an item in the turtle's slot
turtle.place() -- place a block
turtle.drop(count) -- drop an item
turtle.refuel() -- refuel the turtle

If I missed anything, tell me. Also, if you have any questions/comments/additions/snide-remarks, please let me know in the comment, and I'll be right with you :D




Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...
  • brunyman changed the title to ComputerCraft Mod - Turtles Tutorial

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Guidelines.