Advertisement
FailDot

PathFollower

Dec 6th, 2022 (edited)
973
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. local dig = turtle.dig
  2. local turnRight = turtle.turnRight
  3. local turnLeft = turtle.turnLeft
  4. local up = turtle.up
  5. local down = turtle.down
  6. local digUp = turtle.digUp
  7. local forward = turtle.forward
  8.  
  9. local BLOCKS_TO_SEARCH_FOR = {
  10.     "minecraft:iron_ore",
  11.     "minecraft:gold_ore",
  12.     "minecraft:diamond_ore",
  13.     "mysticalagriculture:inferium_ore",
  14.     "thermal:niter_ore",
  15.     "minecraft:dirt"
  16. }
  17.  
  18. local function IsBlockOnList()
  19.     local detect, data = turtle.inspect()
  20.  
  21.     if detect then
  22.         for _,blockName in pairs(BLOCKS_TO_SEARCH_FOR) do
  23.             if blockName == data.name then
  24.                 print("Found", data.name)
  25.                 return data.name
  26.             end
  27.         end
  28.     end
  29. end
  30.  
  31. local function LookAround()
  32.     for i = 1,4 do
  33.         turnRight()
  34.         if IsBlockOnList() then
  35.             dig()
  36.             return true
  37.         end
  38.     end
  39. end
  40.  
  41. while true do
  42.     local found = LookAround()
  43.  
  44.     print(found)
  45.  
  46.     if found then
  47.         dig()
  48.     end
  49.  
  50.     forward()
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement