Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
games:minecraft:public:computer_craft:notable_turtle_programs [2022/12/11 05:02] – clay | games:minecraft:public:computer_craft:notable_turtle_programs [2023/03/13 16:31] (current) – clay | ||
---|---|---|---|
Line 11: | Line 11: | ||
https:// | https:// | ||
+ | |||
+ | updated fork = https:// | ||
+ | |||
+ | another fork = https:// | ||
---- | ---- | ||
Line 72: | Line 76: | ||
-- The turtle is now back at the starting position | -- 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 | -- Loop through the rows again to harvest the crops | ||
for i=1, | for i=1, | ||
Line 106: | Line 113: | ||
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. | 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(" | ||
+ | local size = tonumber(read()) | ||
+ | |||
+ | -- Check that the input is valid | ||
+ | if not size or size <= 0 then | ||
+ | print(" | ||
+ | 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, | ||
+ | -- 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' | ||
+ | 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' | ||
+ | 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. | ||
+ | * | ||
+ | * After the mining is complete, the script calls the returnToStart() function again to drop off any remaining items. | ||
+ | * | ||
+ | * | ||
===== Other ===== | ===== Other ===== | ||