ComputerCraft Forums

ComputerCraft => Programs => APIs and Utilities => Topic started by: w00t on Mar 08, 2024, 10:18 PM

Title: ITurtle - Iterative Turtle Library
Post by: w00t on Mar 08, 2024, 10:18 PM
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 (https://github.com/w00tyd00d/iturtle-cc/wiki) to learn more!

Installation

You can download it as a datapack through the github (https://github.com/w00tyd00d/iturtle-cc).
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.
Title: ITurtle - Iterative Turtle Library
Post by: w00t on Mar 15, 2024, 10:57 PM
I just updated the library to version 1.1, here's a short breakdown of what's been added:

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.