Advertisement
fauxiss

strip2

Apr 30th, 2013
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.86 KB | None | 0 0
  1. local args = {...}
  2.  
  3. -- Check if there is less than 2 arguments
  4. if #args ~= 2 then
  5.   print("Usage: strip <length> <amount>")
  6.   return
  7. end
  8.  
  9. -- Continue with the program
  10. local length = args[1] -- the first argument passed
  11. local amount = args[2] -- the second argument passed
  12.  
  13. -- You can do some checking here
  14. if not tonumber(length) or tonumber(length) < 1 then
  15.   print("length must be a positive number")
  16.   return
  17. end
  18. if not tonumber(amount) or tonumber(amount) < 1 then -- Its saying there is a problem here
  19.   print("amount must be a positive number")
  20.   return
  21. end
  22.  
  23. length = tonumber(length)
  24. amount = tonumber(amount)
  25.  
  26. local function refuel()
  27.     local fuelLevel = turtle.getFuelLevel()
  28.     if fuelLevel == "unlimited" or fuelLevel > 0 then
  29.         return
  30.     end
  31.  
  32.     local function getfuel()
  33.         if turtle.getItemCount(16) == 0  then
  34.             turtle.select(14)
  35.             turtle.place()
  36.             turtle.select(16)
  37.             turtle.suck()
  38.             turtle.select(14)
  39.             turtle.dig()
  40.             turtle.select(1)
  41.         end
  42.         turtle.select(1)
  43.     end
  44.  
  45.     local function tryRefuel()
  46.         for n=1,16 do
  47.             if turtle.getItemCount(n) > 0 then
  48.                 turtle.select(n)
  49.                 if turtle.refuel(1) then
  50.                     turtle.select(1)
  51.                     return true
  52.                 end
  53.             end
  54.         end
  55.         turtle.select(1)
  56.         return false
  57.     end
  58.  
  59.     if not tryRefuel() then
  60.         getfuel()
  61.     end
  62. end
  63.  
  64. local function emptyturtle()
  65.     for s=1,12 do
  66.         if turtle.getItemCount(s) > 0 then
  67.             turtle.select(n)
  68.             if turtle.getItemCount(12) > 0 then
  69.                 turtle.select(13)
  70.                 turtle.place()
  71.                 for ender1 = 1, 12 do
  72.                     turtle.drop()
  73.                 end
  74.                 turtle.select(1)
  75.                 turtle.dig()
  76.                 turtle.transferTo(13)
  77.                 turtle.select(1)
  78.             else
  79.                 break
  80.             end
  81.         end
  82.     end
  83. end
  84.  
  85. torch = 0
  86. local function torched()
  87.     if torch ==  10 then
  88.         turtle.select(15)
  89.         turtle.placeDown()
  90.         turtle.select(1)
  91.         torch = 0
  92.     end
  93. end
  94.  
  95. local function detectup()
  96.     while turtle.detectUp() do
  97.         turtle.digUp()
  98.         sleep(0.4)
  99.     end
  100. end
  101.  
  102. local function strip()
  103.     refuel()
  104.     while not turtle.forward() do
  105.         while not turtle.dig() do
  106.             turtle.attack()
  107.         end
  108.     sleep(0.4)
  109.     detectup()
  110.     emptyturtle()
  111.     end
  112.     torch = torch + 1
  113. end
  114.  
  115. local function otun()
  116.     strip()
  117.     strip()
  118.     turtle.back()
  119.     turtle.back()
  120. end
  121.  
  122. local function turnaround()
  123.     turtle.turnRight()
  124.     strip()
  125.     strip()
  126.     strip()
  127.     otun()
  128.     turtle.turnRight()
  129. end
  130.  
  131. for z = 1, amount do
  132.     refuel()
  133.     for x = 1, length do
  134.         strip()
  135.         torched()
  136.     end
  137.     refuel()
  138.     turnaround()
  139.     x = 0
  140.     refuel()
  141.     for x = 1, length do
  142.         strip()
  143.         torched()
  144.     end
  145.     turtle.turnLeft()
  146.     strip()
  147.     strip()
  148.     strip()
  149.     turtle.turnLeft()
  150.     torch = 0
  151. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement