Advertisement
Gorgozoth

Nether Turtle

Dec 16th, 2022 (edited)
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.53 KB | Gaming | 0 0
  1. local pos = 0
  2. local fuel = "minecraft:lava_bucket"
  3. local keep = {
  4.     [fuel] = true,
  5.     ["minecraft:bucket"] = true,
  6.     ["minecraft:ancient_debris"] = true,
  7.     ["minecraft:diamond_ore"] = true,
  8.     ["minecraft:diamond"] = true,
  9.     ["minecraft:gold_ore"] = true,
  10.     ["minecraft:raw_gold"] = true,
  11.     ["minecraft:gold_nugget"] = true,
  12.     ["minecraft:coal"] = true,
  13.     ["minecraft:bucket"] = true
  14. }
  15.  
  16. local badFluid = "minecraft:lava"
  17. local turtle = turtle
  18. local dir = 1
  19. local length = 16
  20.  
  21. local function refuel()
  22.     for i = 1, 16 do -- for each slot in the chest
  23.         local item = turtle.getItemDetail(i, false)
  24.         if item then -- if there is an item in this slot
  25.             if (string.format("%s", item.name) == fuel) then -- if the item is in the blacklist
  26.                 turtle.select(i)
  27.             end
  28.         end
  29.     end
  30.     while(turtle.getFuelLevel() < 160) do
  31.         turtle.refuel(1)
  32.     end
  33. end
  34.  
  35. local function checkInv()
  36.     for i = 1, 16 do -- for each slot in the chest
  37.         local item = turtle.getItemDetail(i, false)
  38.         if item then -- if there is an item in this slot
  39.             if not keep[string.format("%s", item.name)] then -- if the item is in the blacklist
  40.                 turtle.select(i)
  41.                 turtle.drop()
  42.             end
  43.         end
  44.     end
  45. end
  46.  
  47. local function select()
  48.     for i = 1, 16 do -- for each slot in the chest
  49.         local item = turtle.getItemDetail(i, false)
  50.         if item then -- if there is an item in this slot
  51.             if not keep[string.format("%s", item.name)] then -- if the item is NOT in the blacklist
  52.                 turtle.select(i)
  53.             end
  54.         end
  55.     end
  56. end
  57.  
  58. local function lava()
  59.     local isBlock,block = turtle.inspectUp()
  60.     if isBlock then
  61.         if block.name == "minecraft:lava" then
  62.             turtle.up()
  63.             isBlock,block = turtle.inspectUp()
  64.             if isBlock then
  65.                 if block.name == "minecraft:lava" then
  66.                     select()
  67.                     turtle.placeUp()
  68.                 end
  69.             end
  70.             turtle.down()
  71.         end
  72.     end
  73.     isBlock,block = turtle.inspectDown()
  74.     if isBlock then
  75.         if block.name == "minecraft:lava" then
  76.             turtle.down()
  77.             isBlock,block = turtle.inspectDown()
  78.             if isBlock then
  79.                 if block.name == "minecraft:lava" then
  80.                     select()
  81.                     turtle.placeDown()
  82.                 end
  83.             end
  84.             turtle.up()
  85.         end
  86.     end
  87. end
  88.  
  89. local function loop()
  90.     local ready = true
  91.  
  92.     lava()
  93.  
  94.     while ready do
  95.         while turtle.detect() do
  96.             turtle.dig()
  97.             print("block in front")
  98.         end
  99.         while turtle.detectUp() do
  100.             turtle.digUp()
  101.             print("block on top")
  102.         end
  103.         while turtle.detectDown() do
  104.             turtle.digDown()
  105.             print("block on botem")
  106.         end
  107.        
  108.         if not turtle.detect() then
  109.             ready = false
  110.         end
  111.     end
  112.     lava()
  113.     turtle.forward()
  114. end
  115.  
  116. while true do
  117.    
  118.     if(pos == length) then
  119.         pos = -1
  120.     end
  121.    
  122.     refuel()
  123.  
  124.     loop()
  125.    
  126.     if(pos == -1) then
  127.        
  128.         if(dir == 1) then
  129.             turtle.turnRight()
  130.             dir = 0
  131.             loop()
  132.             turtle.turnRight()
  133.         else
  134.             turtle.turnLeft()
  135.             dir = 1
  136.             loop()
  137.             turtle.turnLeft()
  138.         end
  139.         checkInv()
  140.     end
  141.     pos = pos +1
  142. end
Tags: turtle
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement