Advertisement
warfar

InfMine

May 4th, 2013
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.97 KB | None | 0 0
  1. --Program made by Warfar
  2. --http://pastebin.com/u/warfar
  3. local emptySpace
  4. local slotFound
  5. local empty
  6. amount = {}
  7. local function findEmptySlots()
  8.     for i = 3,16 do
  9.         if turtle.getItemCount(i) == 0 then
  10.             return i
  11.         end
  12.     end
  13.     return 0
  14. end
  15. local function checkRestarted()
  16.     if turtle.getItemCount(1) == 0 then
  17.         turtle.select(1)
  18.         turtle.digUp()
  19.     elseif turtle.getItemCount(2) == 0 then
  20.         turtle.select(2)
  21.         turtle.digUp()
  22.     end
  23. end
  24. local function dropItems()
  25.     while findEmptySlots() == 0 do
  26.         turtle.select(1)
  27.         turtle.digUp()
  28.         if not turtle.placeUp() then
  29.             if turtle.attack() then
  30.                 while turtle.attack() do end
  31.             end
  32.             if turtle.digUp() then
  33.                 while turtle.digUp() do end
  34.             end
  35.         end
  36.         for i = 3,16 do
  37.             turtle.select(i)
  38.             turtle.dropUp()
  39.         end
  40.         while findEmptySlots() == 0 do
  41.             sleep(.1)
  42.             for i = 3,16 do
  43.                 turtle.select(i)
  44.                 turtle.dropUp()
  45.             end
  46.         end
  47.         sleep(1)
  48.     end
  49.     turtle.select(1)
  50.     turtle.digUp()
  51. end
  52. local function dig()
  53.     if turtle.detect() and not turtle.dig() then
  54.         if turtle.attack() then
  55.             while turtle.attack() do end
  56.         end
  57.     end
  58.     if turtle.detectUp() and not turtle.digUp() then
  59.         if turtle.attackUp() then
  60.             while turtle.attackUp() do end
  61.         end
  62.     end
  63.     if turtle.detectDown() and not turtle.digDown() then
  64.         if turtle.attackDown() then
  65.             while turtle.attackDown() do end
  66.         end
  67.     end
  68.     turtle.forward()
  69. end
  70. local function refuel()
  71.     while true do
  72.         if turtle.getFuelLevel() < 10 then
  73.             turtle.select(2)
  74.             if not turtle.placeUp() then
  75.                 if turtle.attack() then
  76.                     while turtle.attack() do end
  77.                 end
  78.                 if turtle.digUp() then
  79.                     while turtle.digUp() do end
  80.                 end
  81.             end
  82.             if findEmptySlots() ~= 0 then
  83.                 e = findEmptySlots()
  84.                 turtle.select(e)
  85.                 turtle.suckUp()
  86.                 while turtle.getItemCount(e) == 0 do
  87.                     sleep(1)
  88.                     turtle.suckUp()
  89.                 end
  90.                 while turtle.getItemCount(e) ~= 0 do
  91.                     turtle.refuel(1)
  92.                 end
  93.                 turtle.select(2)
  94.                 turtle.digUp()
  95.                 break
  96.             end
  97.             if e == 0 then
  98.                 turtle.select(2)
  99.                 turtle.digUp()
  100.                 dropItems()
  101.                 end
  102.         else
  103.         break
  104.         end
  105.     end
  106. end
  107. local function checkSlots()
  108.     if findEmptySlots() == 0 then
  109.         dropItems()
  110.     end
  111. end
  112. checkRestarted()
  113. while true do
  114.     checkSlots()
  115.     refuel()
  116.     dig()
  117. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement