Advertisement
Guest User

strip

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