adamg765

Scale

Feb 3rd, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.92 KB | None | 0 0
  1. local top = 46
  2. local bottom = 7
  3. local width = 63
  4.  
  5. local xSep = 2
  6. local ySep = 4
  7.  
  8. local torches = 2
  9.  
  10. local function refuel()
  11.     if turtle.getFuelLevel() == 0 then
  12.         local prev = turtle.getSelectedSlot()
  13.         turtle.select(1)
  14.         if not turtle.refuel(1) then
  15.             print('Need more fuel')
  16.             while not turtle.refuel(1) do
  17.                 sleep(1)
  18.             end
  19.         end
  20.         turtle.select(prev)
  21.     end
  22. end
  23.  
  24. local function advance()
  25.     if turtle.getSelectedSlot() == 16 then
  26.         print('Need more materials')
  27.         local empty = true
  28.         while empty do
  29.             for n=3, 16 do
  30.                 if turtle.getItemCount(n) > 0 and turtle.getItemDetail(n).name ~= 'chisel:marble' then
  31.                     empty = false
  32.                     turtle.select(n)
  33.                     return
  34.                 end
  35.             end
  36.             sleep(5)
  37.         end
  38.     else
  39.         turtle.select(turtle.getSelectedSlot() + 1)
  40.     end
  41. end
  42.  
  43. local function replace()
  44.     while turtle.detect() do
  45.         turtle.dig()
  46.         sleep(.5)
  47.     end
  48.     local data = turtle.getItemDetail()
  49.     while turtle.getItemCount() == 0 or turtle.getItemDetail().name ~= 'chisel:marble' do
  50.         advance()
  51.     end
  52.     turtle.place()
  53.    
  54. end
  55.  
  56. local function returnToFloor()
  57.     turtle.turnRight()
  58.     while not turtle.forward() do
  59.         turtle.dig()
  60.         sleep(.5)
  61.     end
  62.     turtle.turnLeft()
  63. end
  64.  
  65. local function checkForTorch(x, y)
  66.     if x % 6 == xSep then
  67.         if x % 2 == 0 then
  68.             print(y)
  69.             if (y-1) % 6 == ySep then
  70.                 local prev = turtle.getSelectedSlot()
  71.                 turtle.select(torches)
  72.                 if not turtle.placeUp() then
  73.                     print 'Need more torches'
  74.                     while not turtle.placeUp() do
  75.                         sleep(5)
  76.                     end
  77.                 end
  78.                 turtle.select(prev)
  79.             end
  80.         else
  81.             if (y-1) % 6 == ySep then
  82.                 local prev = turtle.getSelectedSlot()
  83.                 turtle.select(torches)
  84.                 if not turtle.placeUp() then
  85.                     print 'Need more torches'
  86.                     while not turtle.placeUp() do
  87.                         sleep(5)
  88.                     end
  89.                 end
  90.                 turtle.select(prev)
  91.             end
  92.         end
  93.     end
  94. end
  95.            
  96. turtle.select(3)
  97. for i = 1, width, 1 do
  98.      local success, data = turtle.inspect()
  99.         if success then
  100.             if data.name ~= 'chisel:marble' then
  101.                 replace()
  102.             end
  103.         else
  104.             replace()
  105.         end
  106.     for j = bottom, top - 2, 1 do
  107.         refuel()
  108.         if i % 2 == 1 then
  109.             while not turtle.up() do
  110.                 if turtle.detect() then
  111.                     turtle.digUp()
  112.                 elseif turtle.attack() then
  113.                 else
  114.                     sleep(1)
  115.                 end
  116.             end
  117.         else
  118.             while not turtle.down() do
  119.                 if turtle.detect() then
  120.                     turtle.digDown()
  121.                 elseif turtle.attack() then
  122.                 else
  123.                     sleep(1)
  124.                 end
  125.             end
  126.         end
  127.         local success, data = turtle.inspect()
  128.         if success then
  129.             if data.name ~= 'chisel:marble' then
  130.                 replace()
  131.             end
  132.         else
  133.             replace()
  134.         end
  135.         checkForTorch(i,j)
  136.     end
  137.     returnToFloor()
  138. end
Add Comment
Please, Sign In to add comment