feline-dis

Untitled

Dec 24th, 2020 (edited)
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.77 KB | None | 0 0
  1. local slotCount = 16
  2. local width = 25
  3. local length = 25
  4. local height = 3
  5.  
  6. if (arg[1] ~= nil) then
  7.     width = arg[1]
  8.     length = arg[1]
  9. end
  10.  
  11. local trash = {
  12.     "minecraft:cobblestone", "minecraft:stone", "minecraft:andesite",
  13.     "minecraft:diorite", "minecraft:clay_ball", "minecraft:sand",
  14.     "minecraft:sandstone", "minecraft:limestone", "minecraft:dirt",
  15.     "quark:limestone", "minecraft:flint", "rustic:slate", "chisel:limestone2", "chisel:limestone", "minecraft:gravel"
  16. }
  17.  
  18. function checkFuel()
  19.     print('Checking fuel...')
  20.     local refueled = false
  21.     if (turtle.getFuelLevel() < 3000) then
  22.         for slot = 1, slotCount, 1 do
  23.             local item = turtle.getItemDetail(slot)
  24.             if (item ~= nil) then
  25.                 if (item.name == "minecraft:coal" or item.name ==
  26.                     "minecraft:coal_block") then
  27.                     print('Attemping to refuel with %d', item.name)
  28.  
  29.                     turtle.select(slot)
  30.  
  31.                     local result = turtle.refuel()
  32.  
  33.                     refueled = true
  34.                     print('Turtle refueled...')
  35.  
  36.                     break
  37.                 end
  38.             end
  39.         end
  40.         if (refueled == false) then
  41.             print('Did not find coal in inventory.. going to power down soon D:')
  42.         end
  43.         return false
  44.     end
  45. end
  46.  
  47. function digColumn()
  48.     turtle.dig()
  49.     turtle.forward()
  50.     turtle.digUp()
  51.     turtle.digDown()
  52. end
  53.  
  54. function purgeTrash()
  55.     for slot = 1, slotCount, 1 do
  56.         local item = turtle.getItemDetail(slot)
  57.  
  58.         if (item ~= nil) then
  59.             for key, value in pairs(trash) do
  60.                 if (value == item.name) then
  61.                     print("found trash:", item.name)
  62.                     print('trash in slot:', slot)
  63.                     turtle.select(slot)
  64.                     turtle.drop()
  65.                     break
  66.                 end
  67.             end
  68.         end
  69.  
  70.     end
  71. end
  72.  
  73. function turnAround(dir)
  74.     print("turning around...")
  75.     if dir == "right" then turtle.turnRight() end
  76.     if dir == "left" then turtle.turnLeft() end
  77.  
  78.     digColumn()
  79.  
  80.     if dir == "right" then turtle.turnRight() end
  81.     if dir == "left" then turtle.turnLeft() end
  82. end
  83.  
  84. function digBlock()
  85.     while turtle.detect() == false do turtle.forward() end
  86.     for row = 1, width, 1 do
  87.         for col = 1, length, 1 do
  88.             digColumn()
  89.             checkFuel()
  90.             print("col:", col)
  91.             print("length:", length)
  92.             if (col == length) then
  93.                 print('i should probably turn around')
  94.             end
  95.         end
  96.         purgeTrash()
  97.         if row % 2 == 1 then turnAround("right") end
  98.         if row % 2 == 0 then turnAround("left") end
  99.     end
  100. end
  101.  
  102. digBlock()
  103.  
  104.  
  105.  
Advertisement
Add Comment
Please, Sign In to add comment