Advertisement
M0n5t3r

StripMiner2

Apr 17th, 2014
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.64 KB | None | 0 0
  1. local step = 0
  2. local targs = { ... }
  3. steps = tonumber(targs[1])
  4. steps = steps or 1
  5. local left = 0
  6. local back = 0
  7. local right = 0
  8. local z = false
  9. local long = 0
  10. local torchesneeded = 0
  11. local fuelneeded = 0
  12. local torchslotX = 3
  13. local torchslot = 2
  14. local fuelslot = 1
  15. local torchtorch = torchslot
  16. local torchesgot = 0
  17. local fuelneeded = 0
  18. local blocks = 0
  19. local togo = 0
  20. local distance = 0
  21.  
  22.  
  23.  
  24.  
  25.  fuellevel = turtle.getFuelLevel()
  26.  torchesgot = turtle.getItemCount(torchslot)+turtle.getItemCount(torchslotX)
  27.  
  28.  
  29.  -- Math
  30. fuelneeded = steps*5
  31. fuelneeded = fuelneeded+steps
  32. if steps > 3 then
  33.         torchesneeded = steps
  34. else
  35.         torchesneeded = 0
  36. end
  37.  
  38. togo = steps*45
  39. distance = steps*45
  40. -- screen
  41.  
  42. print("Fuel in slot 1")
  43. print("-------------------------------")
  44. print("Fuel needed =     ", fuelneeded)
  45. print("Fuel got =        ", fuellevel)
  46. print("-------------------------------")
  47. print("Torches in slot 2 + 3")
  48. print("-------------------------------")
  49. print("Torches needed =  ", torchesneeded)
  50. print("Torches got =     ", torchesgot)
  51. print("-------------------------------")
  52. print("Blocks to mine = ", togo)
  53. print("To start press ENTER")
  54. read(input)
  55.  
  56. -- Resources
  57.  
  58. if fuellevel < fuelneeded then
  59.         print("  !! insert fuel in slot ", fuelslot)
  60.         repeat
  61.                 sleep(0.5)
  62.                 turtle.select(fuelslot)
  63.                 turtle.refuel()
  64.                 fuellevel = turtle.getFuelLevel()
  65.         until fuellevel > fuelneeded
  66. end
  67.  
  68.  if torchesgot < torchesneeded then
  69.         print("  !! insert torches in slot ", torchslot)
  70.         repeat
  71.                 sleep(0.5)
  72.                 turtle.select(torchslot)
  73.                 torchesgot = turtle.getItemCount(torchslot)+turtle.getItemCount(torchslotX)
  74.         until torchesgot >= torchesneeded
  75. end
  76.  
  77.                                
  78. z = true
  79.  
  80.  
  81.  -- Mining
  82.  
  83.  
  84.          term.clear()
  85.          print("**********************")
  86.          print("Distance to mine:", distance)
  87.          print("**********************")
  88.          print("Torches left:" , turtle.getItemCount(torchslot)+turtle.getItemCount(torchslotX))
  89.          print("**********************")
  90.          print("Fuel level:"  , turtle.getFuelLevel())
  91.          print("**********************")
  92.          print("Blocks mined:", blocks)
  93.          print("**********************")  
  94.          print("Blocks to go:", togo - blocks)
  95.          print("**********************")
  96. turtle.digUp()
  97. turtle.up()
  98. turtle.select(fuelslot)
  99. while z == true do
  100.  
  101.         repeat
  102.                        
  103.                                                 repeat
  104.                                                                 turtle.dig()
  105.                                                                 sleep(0.3)
  106.                                                 until turtle.forward() == true
  107.                         turtle.digUp()
  108.                         turtle.digDown()
  109.                         step = step + 1
  110.                                                 blocks = blocks + 3
  111.                                                 long = long + 1
  112.         until step == 3
  113.         step = 0
  114.         turtle.turnLeft()
  115.          
  116.         repeat
  117.                                                 repeat
  118.                                                                 turtle.dig()
  119.                                                                 sleep(0.3)
  120.                                                 until turtle.forward() == true
  121.                         turtle.digUp()
  122.                         turtle.digDown()
  123.                         left = left + 1
  124.                                                 blocks = blocks + 3
  125.         until left == 6
  126.         left = 0
  127.         turtle.turnRight()
  128.         turtle.turnRight()
  129.  
  130.         repeat
  131.                                                 repeat
  132.                                                                 turtle.dig()
  133.                                                                 sleep(0.3)
  134.                                                 until turtle.forward() == true
  135.                         turtle.digUp()
  136.                         turtle.digDown()
  137.                         back = back + 1
  138.                                                
  139.         until back == 6
  140.         back = 0
  141.          
  142.         repeat
  143.                                                         repeat
  144.                                                                 turtle.dig()
  145.                                                                 sleep(0.3)
  146.                                                 until turtle.forward() == true
  147.                                                 turtle.digUp()
  148.                                                 turtle.digDown()
  149.                         right = right + 1
  150.                                                 blocks = blocks + 3
  151.         until right == 6
  152.         right = 0
  153.         turtle.turnLeft()
  154.         turtle.turnLeft()
  155.          
  156.         repeat
  157.                                                 repeat
  158.                                                                 turtle.dig()
  159.                                                                 sleep(0.3)
  160.                                                 until turtle.forward() == true
  161.                         turtle.digUp()
  162.                         turtle.digDown()
  163.                         back = back + 1
  164.                                                
  165.         until back == 6
  166.         back = 0
  167.         turtle.turnRight()
  168.          
  169.         long = long + 1
  170.                
  171.                 if turtle.getFuelLevel() < 80 then
  172.                                                 turtle.select(fuelslot)
  173.                                                 turtle.refuel()
  174.                 end
  175.                                
  176. -- Check Torches
  177.                 if turtle.getItemCount( torchslot ) < 2 then
  178.                                         term.clear()
  179.                                         print("Going to use torchslot 2")
  180.                                         torchtorch = torchslotX
  181.                                         sleep(0.3)
  182.                 end
  183.                
  184.                 if turtle.getItemCount( torchslotX ) < 2 then
  185.                                         term.clear()
  186.                                         print("going to use torchslot 1")
  187.                                         torchtorch = torchslot
  188.                                         sleep(0.3)
  189.                 end
  190.                
  191.                 if turtle.getItemCount(torchslot) + turtle.getItemCount(torchslotX) < 2 then
  192.                                         term.clear()
  193.                                         print("Need more torches")
  194.                                         z = false
  195.                                                 repeat
  196.                                                                 print("Need more torches...")
  197.                                                                 sleep(0,2)
  198.                                                                 print("Need more torches")
  199.                                                                 sleep(0,2)
  200.                                                                 print("Need more torches...")
  201.                                                                 sleep(0,2)
  202.                                                                 print("Need more torches")
  203.                                                         until turtle.getItemCount(torchslot) + turtle.getItemCount(torchslotX) > 2
  204.  
  205.                                                                                                                 z = true
  206.  
  207.                                                                                                                 end
  208.  
  209.  -- Place torches
  210.  
  211.         turtle.select(torchtorch)
  212.         turtle.placeDown()
  213.  
  214.  
  215.                 --Termenator Clear + Update
  216.          term.clear()
  217.          print("**********************")
  218.          print("Distance to mine:", distance)
  219.          print("**********************")
  220.          print("Torches left:" , turtle.getItemCount(torchslot)+turtle.getItemCount(torchslotX))
  221.          print("**********************")
  222.          print("Fuel level:"  , turtle.getFuelLevel())
  223.          print("**********************")
  224.          print("Blocks mined:", blocks)
  225.          print("**********************")  
  226.          print("Blocks to go:", togo - blocks)
  227.          print("**********************")
  228.  
  229.  end
  230.  
  231. if(long == steps*3) then
  232.         z = false
  233.                 turtle.turnLeft()
  234.                 turtle.turnLeft()
  235.                 repeat
  236.                         turtle.forward()
  237.                         long = long - 1
  238.                 until long == 0
  239. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement