Advertisement
adamg765

ScaleMC

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