XMedders Posted December 22, 2015 Share Posted December 22, 2015 Turtles! How cute! [and deadly] Turtles! Lovable, programmable... reptiles! No, no, no. Not those kind of turtles! These turtles http://computercraft.info/wp-content/uploads/2012/07/piggy.png 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: Quote 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 print(i) end --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 turtle.forward() end end 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 turtle.forward() end end go(3) turtle.turnLeft() go(3) turtle.turnLeft() go(3) turtle.turnLeft() go(3) turtle.turnLeft() --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.forward() turtle.back() turtle.up() turtle.down() turtle.turnLeft() turtle.turnRight() 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 Thanks-a-million -XMedders rmtworks and DonVanhugenstyn 2 Quote Link to comment Share on other sites More sharing options...
DonVanhugenstyn Posted December 23, 2015 Share Posted December 23, 2015 Careful when allowing turtles for the entire town. I would suggest you use /town perm plot set ccturtles true And set that plot somewere withing the town so that turtles cannot penetrate. That way a rogue turtle cant be sent in to do bad things to your town. XMedders 1 Quote Link to comment Share on other sites More sharing options...
XMedders Posted December 23, 2015 Author Share Posted December 23, 2015 Wise words from this man everybody! Editing right now Quote Link to comment Share on other sites More sharing options...
cmyk Posted February 5, 2016 Share Posted February 5, 2016 This tutorial helped me so much! Thanks Quote Link to comment Share on other sites More sharing options...
Conspiracy Posted February 9, 2016 Share Posted February 9, 2016 Well done. Nice work with that tutorial like with each other of yours XMedders 1 Quote Link to comment Share on other sites More sharing options...
XMedders Posted February 25, 2016 Author Share Posted February 25, 2016 Well done. Nice work with that tutorial like with each other of yours Thanks, I enjoy the art of coding, and I believe it is an essential skill for all people in this day in age. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.