Skip to content

Importing Programs

Ivaynn edited this page Jul 6, 2024 · 3 revisions

Importing Instructions

If you want to import pre-made programs, use /trigger tc.trigger set 1, replacing 1 with numbers up to 7 will import some examples included with the data pack:

ID Description
1 Dig a rectangular hole with a specified size
2 Place an oak sapling. Once it grows, collect the logs and restart. Requires oak saplings
3 Build and maintain a carrot farm. Requires dirt, carrots and an equipped hoe
4 Move in random directions
5 Go to specific coordinates x / y / z
6 Dig a rectangular hole with a specified size in a spiral pattern
7 Dig a 3x3 tunnel forward with a specified length

If you want to import a different program, follow this section.


Exporting Instructions

To export a program from a turtle, you can use the F3 + I key combination while facing the turtle to copy its data to your clipboard. From there, you can paste it into a text editor and find the Instructions list, which should be inside ArmorItems.

Alternatively, you can save a turtle's program to a music disc by sneaking and hitting the turtle with the disc. You can then see the instructions stored in the disc by using /data get entity @s SelectedItem.tag.Instructions and then copy it from your chat log. If you don't see the chat message, make sure the gamerule sendCommandFeedback is set to true.

You should end up with something like this:

[{Version:2, PauseOnError: 1b, AutoFuel: 0b, SafeMine: 1b, Locked: 1b, ShowText: 0b, ClearCounters: 1b, Silent: 0b, AutoMine: 1b, DamagePlayers: 0b}, {A: {direction: "forward"}, C: 1}, {A: {item: "minecraft:stone", direction: "down"}, C: 5}, {A: {operation: "set", line: 1}, C: 95}]

Note: the Version at the beginning represents the version of the data pack, changing it manualy is not recommended!

You can share this list with someone, and they will be able to import the program into their world.


Editing Pre-made Programs

For this section, you'll need to edit your copy of the data pack. Inside the data pack files, go to the data/tc/functions folder and open import.mcfunction. Add a new line at the end with the command below, where [...] is a list of instructions like the one in the example above and <your chosen ID> is a unique numeric ID (a positive integer).

execute if score @s tc.trigger matches <your chosen ID> run data modify storage tc:tmp import set value [...]

The final command should look something like this:

execute if score @s tc.trigger matches 8 run data modify storage tc:tmp import set value [{Version:2, PauseOnError: 1b, AutoFuel: 0b, SafeMine: 1b, Locked: 1b, ShowText: 0b, ClearCounters: 1b, Silent: 0b, AutoMine: 1b, DamagePlayers: 0b}, {A: {direction: "forward"}, C: 1}, {A: {item: "minecraft:stone", direction: "down"}, C: 5}, {A: {operation: "set", line: 1}, C: 95}]

Save your changes, go back to the game and use /reload. Now anyone in your world (or server) can import the instructions you just saved. To do that, hold a music disc and use the following command, where <your chosen ID> is the numeric ID you defined above.

/trigger tc.trigger set <your chosen ID>