Advertisement
Guest User

strip.lua

a guest
Apr 8th, 2020
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.22 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.  
  6. loc = {1,0}
  7. face = "north"
  8. resumeloc = {1,0,"north"}
  9.  
  10. function search(x)
  11.     for i=1,16,1 do
  12.         print(i)
  13.         if turtle.getItemDetail(i) ~= nil then    
  14.        
  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.     else
  38.         turtle.select(slot)
  39.         turtle.refuel(turtle.getItemCount())
  40.         turtle.select(1)
  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.             resumeloc[1] = loc[1]
  66.             resumeloc[2] = loc[2]
  67.             resumeloc[3] = face
  68.             goHome(loc)
  69.             dump()
  70.             resume(resumeloc)
  71.         end
  72.     end
  73. end
  74.  
  75. function bigDig(x,y)
  76.     dig(2)
  77.     for i=1, x , 1 do
  78.         dig(y)
  79.         if face == "north" then
  80.             turtle.turnRight()
  81.             face = "east"
  82.             dig(2)
  83.             turtle.turnRight()
  84.             face = "south"
  85.         elseif face == "south" then
  86.             turtle.turnLeft()
  87.             face = "east"
  88.             dig(2)
  89.             turtle.turnLeft()
  90.             face = "north"
  91.         end
  92.     end    
  93. end
  94.  
  95. function resume(x)
  96.     for i=1 , x[2], 1 do
  97.         turtle.forward()
  98.         locUpdate()
  99.     end
  100.     turtle.turnRight()
  101.     face = "east"
  102.     for i=2 , x[1], 1 do
  103.         turtle.forward()
  104.         locUpdate()
  105.     end
  106.     if resumeloc[3] == "south" then
  107.         turtle.turnRight()
  108.         face = "south"
  109.     elseif resumeloc[3] == "north" then
  110.         turtle.turnLeft()
  111.         face = "north"
  112.     end          
  113. end
  114. function goHome(x)
  115.     if face == "south" then
  116.         turtle.turnRight()
  117.     elseif face == "north" then
  118.         turtle.turnLeft()
  119.     elseif face == "east" then
  120.         turtle.turnLeft()
  121.         turtle.turnLeft()
  122.     end
  123.     face = "west"
  124.     if x[1] ~= 1 then
  125.         for i=2,x[1],1 do
  126.             turtle.forward()
  127.             locUpdate()
  128.         end
  129.     end
  130.     turtle.turnLeft()
  131.     face = "south"
  132.     for i=1, x[2], 1 do
  133.         turtle.forward()
  134.         locUpdate()
  135.         print(loc[1],loc[2])
  136.     end
  137.     turtle.turnLeft()
  138.     turtle.turnLeft()
  139.     face = "north"
  140. end
  141.  
  142. function dump()
  143.     for i=1, 16, 1 do
  144.         turtle.select(i)
  145.         turtle.dropDown()
  146.     end
  147.     turtle.select(1)
  148. end
  149.  
  150. bigDig(num2,num1)
  151. goHome(loc)
  152. dump()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement