====== Notable Turtle Programs ====== ===== Quarries ===== https://www.computercraft.info/forums2/index.php?/topic/5681-variable-size-quarry-now-with-super-ore-quarry%e2%84%a2/ https://pastebin.com/rpXRAZs4 See [[games:minecraft:public:computer_craft:quarry_script|this article]] for more info ---- https://github.com/Starkus/quarry updated fork = https://github.com/Baynar/quarry another fork = https://github.com/jeong-jaegyu/quarry ---- ===== Strip Mines ===== https://www.computercraft.info/forums2/index.php?/topic/29683-ore-collecting-miner-a-very-advanced-mining-program/ https://pastebin.com/gkz5sgZ8 ---- https://www.computercraft.info/forums2/index.php?/topic/19556-advanced-branch-mining-turtle-with-self-setup/ This one lays torches but requires two scripts, a setup and a mine program. It's much more complicated and not worth the time IMO. ---- ===== Farming ===== From ChatGPT -- This turtle will plant and harvest a 20 by 20 area -- First, define the size of the area local area_width = 20 local area_length = 20 -- Next, move the turtle to the starting position -- (assume that the turtle is facing the correct direction) turtle.forward() -- Now, loop through the rows for i=1,area_length do -- Plant seeds on this row for j=1,area_width do turtle.placeDown() turtle.forward() end -- Move the turtle back to the beginning of the row for j=1,area_width do turtle.back() end -- Move the turtle to the next row turtle.turnRight() turtle.forward() turtle.turnRight() end -- Now, the turtle is at the end of the last row -- Move it back to the starting position for i=1,area_length do turtle.back() end turtle.turnLeft() for i=1,area_width do turtle.back() end turtle.turnLeft() -- The turtle is now back at the starting position turtle.sleep(600) -- sleep for 10 minutes -- Loop through the rows again to harvest the crops for i=1,area_length do -- Harvest the crops on this row for j=1,area_width do turtle.digDown() turtle.forward() end -- Move the turtle back to the beginning of the row for j=1,area_width do turtle.back() end -- Move the turtle to the next row turtle.turnRight() turtle.forward() turtle.turnRight() end -- Now, the turtle is at the end of the last row -- Move it back to the starting position for i=1,area_length do turtle.back() end turtle.turnLeft() for i=1,area_width do turtle.back() end turtle.turnLeft() -- Done! This script will plant seeds in a 20 by 20 area and then return to the starting position to harvest the crops. Note that this script assumes that the turtle has enough seeds and fuel to complete the task, and that it is facing the correct direction when it starts. ===== Mining ===== ChatGPT mining script -- Ask the user for the size of the mine print("What size should the mine be?") local size = tonumber(read()) -- Check that the input is valid if not size or size <= 0 then print("Invalid size") return end -- Define a function to dig down to bedrock local function digDown() while turtle.detectDown() do turtle.digDown() end turtle.down() end -- Define a function to return to the starting point local function returnToStart() -- Face the turtle towards the starting point turtle.turnLeft() turtle.turnLeft() -- Move back to the starting point for i = 1, size - 1 do turtle.forward() end -- Drop off items for i = 1, 16 do turtle.select(i) turtle.drop() end -- Keep 1 stack of coal turtle.select(1) turtle.transferTo(16, 64) -- Refuel with coal turtle.select(16) turtle.refuel() end -- Pull a stack of coal from the chest turtle.select(1) turtle.suck(64) -- Dig out the mine for i = 1, size do for j = 1, size do -- Dig out a layer of the mine for k = 1, size do -- Check if the turtle's inventory is full if turtle.getItemCount(16) > 0 then returnToStart() -- Return to starting point and drop off items end -- Dig out a block turtle.dig() turtle.forward() end -- Move to the next layer if j < size then if j % 2 == 0 then turtle.turnRight() turtle.dig() turtle.forward() turtle.turnRight() else turtle.turnLeft() turtle.dig() turtle.forward() turtle.turnLeft() end end end -- Move to the next layer if i < size then turtle.turnLeft() turtle.dig() turtle.forward() turtle.turnLeft() end digDown() -- Dig down to bedrock end returnToStart() -- Return to starting point and drop off items -- Resume mining for i = 1, size do for j = 1, size do -- Dig out a layer of the mine for k = 1, size do -- Check if the turtle's inventory is full if turtle.getItemCount(16) > 0 then returnToStart() -- Return to starting point and drop off items end -- Dig out a block turtle.dig() turtle.forward() end -- Move to the next layer if j < size then if j % 2 == 0 then turtle.turnRight() turtle.dig() turtle.forward() turtle.turnRight() else turtle.turnLeft() turtle.dig() turtle.forward() turtle.turnLeft() end end end -- Move to the next layer if i < size then turtle.turnLeft() turtle.dig() turtle.forward() turtle.turnLeft() end digDown() -- Dig down to bedrock end Here's how the updated script works: * The script defines a new returnToStart() function that the turtle will use to return to its starting point, drop off its items, and pull a stack of coal from a chest. * Inside the dig out a layer of the mine loop, the script checks whether the turtle's inventory is full using the getItemCount() function. If the turtle's inventory is full, it calls the returnToStart() function to return to the starting point and drop off its items. * After the mining is complete, the script calls the returnToStart() function again to drop off any remaining items. * Inside the returnToStart() function, the turtle first turns around to face the starting point, then moves back to the starting point using a for loop. It then uses another for loop to drop off all items in its inventory. * Finally, the returnToStart() function selects the first slot in the turtle's inventory (assumed to contain coal) and uses the suck() function to pull a stack of 64 coal from a chest. ===== Other =====