ITurtle - Iterative Turtle Library

Started by w00t, Mar 08, 2024, 10:18 PM

Previous topic - Next topic

w00t

ITurtle: The Iterative Turtle Library

ITurtle is a wrapper library built to add iterative functionality to ComputerCraft turtles in a declarative fashion. Many of the default turtle methods have been given a "count" parameter to allow repetition of the same instruction, along with the addition of many new quality of life functions to aid in complex turtle program development.

Want to mine out a whole chunk 100 layers down?

local t = require("iturtle")

local function mineLayer()
    t.loopSwap(function()
        t.dig(nil, 16, true)
    end, function()
        t.turnAroundRight(1, true)
    end, 16)
end

local function stageNewLayer()
    t.digDown(nil, 1, true)
    t.turnRight(2)
end

t.loopSwap(mineLayer, stageNewLayer, 100)

Check out the API documentation to learn more!

Installation

You can download it as a datapack through the github.
Alternatively, you can download the source file directly using this command on any turtle in-game.

pastebin get P6wD0Lpf iturtle.lua
Just bear in mind the datapack version gets automatically inserted into every turtle's ROM directory, and therefore doesn't take up memory on their drive.

w00t

I just updated the library to version 1.1, here's a short breakdown of what's been added:
  • New navigation methods for instructing turtles to specific points in the world
  • New location bookmarking feature to save coordinates
  • New shell program interface

patch notes here:
https://github.com/w00tyd00d/iturtle-cc/blob/main/NOTES.md#version-11

Let me know what you all think o7 leave any questions or feedback below.