This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Luanub's profile picture

Turtle Tree Farmer Movement API

Started by Luanub, 20 March 2012 - 10:04 AM
Luanub #1
Posted 20 March 2012 - 11:04 AM
The Turtle Control System API improves on the Default Turtle API to make the movements more intelligent and allow the user to specify the number blocks the turtle is to move.

The Turtle will destroy any block that gets in its path. Additionally if a mob or player steps in front of the Turtle it will stop and wait until its path is clear before it proceeds. This ensures that your turtle will follow the correct path and place items with accuracy.

There is also a function to harvest tree's and prep the specified area for planting.

Hopefully this will save some time and simple your coding some.

To install download the file from below and for SSP save the file to your %APPDATA%/.minecraft/mods/ComputerrCraft/lua/rom/apis/turtle folder.

For SMP save the file to your minecraftserver/mods/ComputerCraft/lua/rom/apis/turtle folder.

Alternatively you can save the file in your computers root directory and us os.loadAPI("TCS") in the start of your program to load the API manually. To unload the API simply use os.unloadAPI("TCS").

Functions:
Spoilerback() moves the turtle back the specified number of blocks, will wait for its path to be clear before moving.
- example: TCS.back( 5 ) - 5 spaces back

forward() moves the turtle forward the specified number of blocks, will destroy blocks in its path, and wait for its path to be clear before moving.
- example: TCS.forward( 5 ) - 5 spaces forward

up() moves the turtle up the specified number of spaces, will wait for its path to be clear before moving.
- example: TCS.up( 10 ) - 10 spaces up

down() moves the turtle down the specified number of spaces, will wait for its path to be clear before moving.
- example: TCS.down() - 1 space down

placeDown() places a block from the specified slot under the turtle. Will remove the block under the turtle prior to placement if one exist.
- example: TCS.placeDown()

harvestTree() will harvest a tree if there is one in front of the turtle.
- example: TCS.harvestTree()

prepSpace() will prepare the block for planting by removing any blocks above the block, and ensuring that the block is the same as the block in the selected inventory slot.
- example:
Place dirt in slot 1
turtle.select( 1 )
TCS.prepSpace( 10 ) - will prep the next 10 blocks

Video:
Spoiler[media]http://youtu.be/QK5Y-ES4u-4[/media]

Download: TCS
Edited on 17 April 2012 - 12:11 AM
Chriswil1451021 #2
Posted 16 April 2012 - 10:48 AM
I put the file where you said to but for some reason i keep getting this error when i type the TCS.forward(1)

lua:1: attempt to index ? (a nil value)

And the rest does the same

can you please explain how to install and use better so that i might be abele to understand it?
Luanub #3
Posted 17 April 2012 - 02:14 AM
I've updated the instruction and included the file as a download vs source coding to hopefully make that portion easier.

Make sure the API is loaded before trying your program by typing apis from the terminal. If it is not try to manually load it.

Also make sure the file is named TCS, if it is not you will have to use whatever you named the file to call the function. example: filename.forward(1)

If it is loaded and named as TCS, TCS.forward(1) should work. From the error it sounds like the API is more then likely not loaded. If you have further issues let me know and I'll see what I can do to help.
Zee #4
Posted 18 July 2013 - 11:39 PM
Hey. Would you mind if I used this in my OS when i edit it for turtles? I'll provide proper credit.

Edit: I am a master post necro-er now. *le fail*