Advertisement
chopstyix

chop.lua

Jan 23rd, 2022 (edited)
777
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var_sleepTimer = .5
  2.  
  3. function getBlockName()
  4.   local success,data = turtle.inspect()
  5.   return data.name
  6. end
  7.  
  8. -- function detectSapling()
  9.   -- local success,data = turtle.inspect()
  10.   -- return data.tags["minecraft:saplings"]
  11. -- end
  12.  
  13. function chopWood()
  14.   local loop = true
  15.   while loop do
  16.     if getBlockName() == "myrtrees:rubberwood_log" or getBlockName() == "myrtrees:filled_rubberwood_log" then
  17.       turtle.dig()
  18.       turtle.digUp()
  19.       turtle.up()
  20.     else
  21.       loop = false
  22.     end
  23.   end
  24. end
  25.    
  26. -- MAIN CODE --
  27.  
  28. -- Turtle Detect
  29. while true do
  30.   local success,data = turtle.inspectDown()
  31.   -- if turtle detects a white concrete block below, then turtle moves forward
  32.   if data.name == "minecraft:white_concrete" then
  33.     turtle.forward()
  34.   -- if turtle detects a blue concrete block below, then turtle turns right and attempts chopWood(), turn left and move foward
  35.   elseif data.name == "minecraft:blue_concrete" then
  36.     turtle.turnRight()
  37.     print("Detecting Block...")
  38.     if getBlockName() == "myrtrees:rubberwood_log" or getBlockName() == "myrtrees:filled_rubberwood_log" then
  39.       print("Wood Detected!")
  40.       chopWood()
  41.     end  
  42.     print("No Wood Detected")  
  43.     print("Going Down!")
  44.     while turtle.inspectDown() == false do
  45.       turtle.down()
  46.     end
  47.     turtle.turnLeft()
  48.     turtle.forward()
  49.   -- if turtle detects a yellow concrete block below, then turtle turns right and moves forward
  50.   elseif data.name == "minecraft:yellow_concrete" then
  51.     turtle.turnRight()
  52.     turtle.forward()
  53.   elseif data.name == "minecraft:red_concrete" then
  54.     turtle.turnRight()
  55.     sleep(600)
  56.     turtle.forward()
  57.   else
  58.     print("Error!")
  59.   end
  60. sleep(var_sleepTimer)
  61. term.clear()
  62. term.setCursorPos(1,1)
  63. print("Current Fuel: ", turtle.getFuelLevel())
  64. end
  65.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement