Advertisement
Guest User

strip

a guest
Apr 10th, 2020
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.62 KB | None | 0 0
  1.  
  2. num1 = 16
  3. num2 = 16
  4. num3 = 30
  5.  
  6. loc = {1,1}
  7. face = "north"
  8. resumeloc = {1,0,"north"}
  9.  
  10. function search(x)
  11.     for i=1,16,1 do
  12.         if turtle.getItemDetail(i) ~= nil then            
  13.             if turtle.getItemDetail(i).name == x then
  14.                 return i
  15.             end
  16.         end
  17.     end    
  18. end
  19.  
  20. function fuelCheck()
  21.     local a = num1*num2
  22.     local b = turtle.getFuelLevel()
  23.     if a>b then
  24.         return false
  25.     else
  26.         return true
  27.     end  
  28. end
  29.  
  30. function refuel()
  31.     local slot = search("minecraft:coal")
  32.     if slot == nil then
  33.         print("i got no fuel")
  34.         turtle.select(1)
  35.         return false
  36.     else
  37.         turtle.select(slot)
  38.         turtle.refuel(turtle.getItemCount())
  39.         turtle.select(1)
  40.         return true
  41.     end
  42. end
  43. function locUpdate()
  44.     if face == "north" then
  45.         loc[2] = loc[2] + 1
  46.     elseif face == "south" then
  47.         loc[2] = loc[2] - 1
  48.     elseif face == "east" then
  49.         loc[1] = loc[1] + 1
  50.     elseif face == "west" then
  51.         loc[1] = loc[1] - 1
  52.     end
  53. end
  54. function dig(x)
  55.     for i=2, x, 1  do
  56.         turtle.dig()
  57.         while turtle.detect() do
  58.             turtle.dig()  
  59.         end  
  60.         turtle.forward()
  61.         locUpdate()
  62.         turtle.digUp()
  63.         turtle.digDown()
  64.         if turtle.getItemDetail(16) ~= nil then
  65.             refuel()
  66.             dump()
  67.         end
  68.     end
  69. end
  70.  
  71. function bigDig(x,y)
  72.  
  73.     for i=1, x , 1 do
  74.         dig(y)
  75.         if i~=x then
  76.             if face == "north" then
  77.                 turtle.turnRight()
  78.                 face = "east"
  79.                 dig(2)
  80.                 turtle.turnRight()
  81.                 face = "south"
  82.             elseif face == "south" then
  83.                 turtle.turnLeft()
  84.                 face = "east"
  85.                 dig(2)
  86.                 turtle.turnLeft()
  87.                 face = "north"
  88.             end
  89.         end
  90.     end
  91.     goHome(loc)
  92.     dump()    
  93. end
  94.  
  95.  
  96. function goHome(x)
  97.     if face == "south" then
  98.         turtle.turnRight()
  99.     elseif face == "north" then
  100.         turtle.turnLeft()
  101.     elseif face == "east" then
  102.         turtle.turnLeft()
  103.         turtle.turnLeft()
  104.     end
  105.     face = "west"
  106.     if x[1] ~= 1 then
  107.         for i=2,x[1],1 do
  108.             turtle.forward()
  109.             locUpdate()
  110.         end
  111.     end
  112.     turtle.turnLeft()
  113.     face = "south"
  114.     for i=2, x[2], 1 do
  115.         turtle.forward()
  116.         locUpdate()
  117.     end
  118.     turtle.turnLeft()
  119.     turtle.turnLeft()
  120.     face = "north"
  121. end
  122.  
  123. function dump()
  124.     turtle.select(1)
  125.     turtle.placeDown()
  126.     for i=1, 16, 1 do
  127.         turtle.select(i)
  128.         turtle.dropDown()
  129.     end
  130.     turtle.select(1)
  131.     turtle.digDown()
  132. end
  133. function setup()
  134.     a = num1*num2*1.75
  135.     if turtle.getItemDetail(1).name ~= "enderstorage:ender_storage" then
  136.         print("ender chest needed in slot 1")
  137.         return false
  138.     end
  139.     if turtle.getFuelLevel()<a then
  140.         return(refuel())
  141.     else
  142.         return true
  143.     end
  144. end
  145. function down3(x)
  146.     turtle.digDown()
  147.     turtle.down()
  148.    
  149.     for i=1, 2, 1 do
  150.         if turtle.digDown() then
  151.             turtle.down()
  152.         elseif turtle.down() then
  153.         else
  154.             turtle.up()
  155.             x = num3
  156.             return x
  157.         end
  158.     end
  159.    if turtle.digDown() then
  160.    elseif turtle.detectDown() then
  161.        turtle.up()
  162.        x = num3
  163.        return x
  164.    end
  165. end
  166. if setup() then
  167.     for i=1 ,num3 ,1 do
  168.         bigDig(num2,num1)
  169.         down3(i)    
  170.     end
  171.    
  172.     for j=1, 24, 1 do
  173.         turtle.up()
  174.         turtle.up()
  175.         turtle.up()
  176.     end
  177. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement