Page cover

CCTurtles

An attempt to copy Computercraft's Turtles

Overview

CCTurtles is a project with many hours of work. It makes it possible to control a gold block using Scripts. Sadly minescript only allows for using /setblock for moving the block so it is not possible to use this on servers or worlds where you do not have OP permissions. The Turtles are programmed in Python in a new file.

Getting Started

First, you download CCTurtles. (Not available yet!)

Now you can save scripts that you make yourself (or download) in the same folder.

Let's go through the process of creating a script together, shall we?

First, create a file. We will take examplescript.py as an example. In there you now write from ccturtles import Turtle. Now you can start writing normal python code. Commands (with their Description) are listed below. When done, you look at one side of a gold block (not top or bottom) and run \ccturtles run examplescript. The code should now run and you can see the results.

Ingame Commands

\ccturtles run <scriptname>

Runs the file .minecraft/minescript/<scriptname>.py. The file extension is not needed!

Scripting Commands

Turtle(x:int,y:int,z:int,direction:int,name:str) -> class object

Create a new Turtle at xyz with the specified direction. Also see: Turtle.name. THIS DOES NOT NEED TO BE CALLED AT THE START OF SCRIPTS! THIS IS ONLY FOR CREATING MULTIPLE TURTLES WITH THE SAME SCRIPT! âš  When one Turtle get's stopped (by bedrock as an example) all turtles in the same script stop too!

Turtle.forward(check:bool=True)

Moves the Turtle forward. This is the direction you looked at when you ran the script. You can change the direction by using Turtle.turnLeft() or Turtle.turnRight()

Arguments: check:bool - Defines whether to check if there is bedrock where you want to move and in this case stop the script. This is enabled by default.

Turtle.backward(check:bool=True)

Moves the Turtle backward. This is the opposite side of the side you looked at when you ran the script. You can change the direction by using Turtle.turnLeft() or Turtle.turnRight()

Arguments: check:bool - Defines whether to check if there is bedrock where you want to move and in this case stop the script. This is enabled by default.

Turtle.turnLeft()

Changes the Direction Turtle.forward() and Turtle.backward() move in.

Turtle.turnRight()

Changes the Direction Turtle.forward() and Turtle.backward() move in.

Turtle.dropAll(itemid:str) -> bool

Drops all items in the turtle's inventory (if any) with the given itemid. If none is given it will drop all Items in the inventory.

Arguments: itemid:str - The Itemid of the item to drop. Example: minecraft:grass_block Returns: success:bool - If the action was successful. Returns False if the item does not exist in the inventory

Turtle.mineFront(check:bool=True)

Mines the block in front of the Turtle and puts it into the Turtle's Inventory. This is the block on the side of the turtle you looked at when you ran the script. You can change the direction by using Turtle.turnLeft() or Turtle.turnRight()

Arguments: check:bool - Defines whether to check if there is bedrock where you want to mine and in this case stop the script. This is enabled by default.

Turtle.mineUp(check:bool=True)

Mines the block above the Turtle and puts it into the Turtle's Inventory.

Arguments: check:bool - Defines whether to check if there is bedrock where you want to mine and in this case stop the script. This is enabled by default.

Turtle.mineDown(check:bool=True)

Mines the block below the Turtle and puts it into the Turtle's Inventory

Arguments: check:bool - Defines whether to check if there is bedrock where you want to mine and in this case stop the script. This is enabled by default.

Turtle.getFrontBlock() -> str

Returns the blockid of the Block in front of the Turtle. This is the block on the side of the turtle you looked at when you ran the script. You can change the direction by using Turtle.turnLeft() or Turtle.turnRight()

Returns: block:str - The block id of the block. Examples: minecraft:grass_block minecraft:air minecraft:stone

Turtle.getTopBlock() -> str

Returns the blockid of the Block above the Turtle.

Returns: block:str - The block id of the block. Examples: minecraft:grass_block minecraft:air minecraft:stone

Turtle.getBottomBlock() -> str

Returns the blockid of the Block below the Turtle.

Returns: block:str - The block id of the block. Examples: minecraft:grass_block minecraft:air minecraft:stone

Turtle.moveUp(check:bool=True)

Moves the Turtle one block up.

Arguments: check:bool - Defines whether to check if there is bedrock where you want to mine and in this case stop the script. This is enabled by default.

Turtle.moveDown(check:bool=True)

Moves the Turtle one block down.

Arguments: check:bool - Defines whether to check if there is bedrock where you want to mine and in this case stop the script. This is enabled by default.

Turtle.placeFront(block:str) -> bool

Places a block in front of the Turtle. This is the direction you looked at when you ran the script. You can change the direction by using Turtle.turnLeft() or Turtle.turnRight()

Arguments: block:str - The blockid of the block that you want to place. Example: minecraft:grass_block Returns: success:bool - returns whether the block got places. Returns False if the block was not found in the Inventory.

Turtle Variables

Turtle.inventory

Every Turtle has it's own Inventory. This Inventory get's lost when stopping the script so you should put Turtle.dropAll() at the end of your Script if it involves mining blocks for you. This Variable is a list of every item in the inventory shaped like this: ["minecraft:grass_block", "minecraft:grass_block", "minecraft:grass_block"]. Every entry is a single item. You can remove and add items by using Turtle.inventory.append() and Turtle.inventory.remove(). Note that removing an item throws an error if the item is not in the Inventory. Using if item in Turtle.inventory is also possible and great for checking if an item is in the inventory!

Turtle.x, Turtle.y, Turtle.z

The Coordinates of the Turtle.

Turtle.direction

Specifies the direction the turtle moves in when calling Turtle.forward() or Turtle.backward(). This can be changed using Turtle.turnLeft() and Turtle.turnRight(). The direction is given as an int as follows: 1 = North 2 = East 3 = South 4 = West

Turtle.name

Currently has no use case. "Turtle" by default, can be changed using Turtle.name = "new name". Can optionally be used to store data of the turtle.

Last updated