games:minecraft:public:computer_craft:notable_turtle_programs

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
games:minecraft:public:computer_craft:notable_turtle_programs [2022/12/11 05:10] claygames:minecraft:public:computer_craft:notable_turtle_programs [2023/03/13 16:31] (current) clay
Line 11: Line 11:
  
 https://github.com/Starkus/quarry https://github.com/Starkus/quarry
 +
 +updated fork = https://github.com/Baynar/quarry
 +
 +another fork = https://github.com/jeong-jaegyu/quarry
  
 ---- ----
Line 109: 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
 +<code>
 +-- 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
 +</code>
 +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 ===== ===== Other =====
  
  
  • games/minecraft/public/computer_craft/notable_turtle_programs.1670735412.txt.gz
  • Last modified: 2022/12/11 05:10
  • by clay