Advertisement
M0n5t3r

Miner Bot 2016

Aug 31st, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.61 KB | None | 0 0
  1. --start
  2.  
  3. term.write("Insert Length: ")
  4. Length = tonumber(read())
  5. print(" ")
  6.  
  7. term.write("Insert Width: ")
  8. Width = tonumber(read())
  9. print(" ")
  10.  
  11. term.write("Insert Height Devided by 3: ")
  12. Height = tonumber(read())
  13. print(" ")
  14.  
  15. local fuelslot = 1
  16. local torchslot = 2
  17. local counter = 0
  18. local Height = Height
  19. local Length = Length
  20. local Width = Width
  21. local xLength = 0
  22. local xHeight = 0
  23. local xWidth = 0
  24. local down = 0
  25. local i = 3
  26. local DrieHeight = Height * 3
  27.  
  28. local x = 0
  29. local y = 0
  30. local z = 0
  31. local xx = 0
  32. local yy = 0
  33. local zz = 0
  34.  
  35.     print("*** Miner Bot By Fish ***")
  36.     print("    Fuelslot = 1")
  37.     print("    Torchslot = 2")
  38.     print("*************************")
  39.     print("Length =" .. Length)
  40.     print("Height =" .. Height * 3)
  41.     print("Width =" .. Width)
  42.     print("*************************")
  43.     print("fuel needed =" .. Length * Width * DrieHeight)
  44.     print("*************************")
  45. sleep(1)
  46.  
  47.  
  48. --fuel check
  49.  
  50. function fuelslotcheck()
  51.     if turtle.getItemCount(fuelslot) < 1 then
  52.         turtle.select(fuelslot)
  53.         turtle.turnLeft()
  54.         turtle.turnLeft()
  55.         print("put fuel in the chest!")
  56.         repeat
  57.             turtle.suck()
  58.         until turtle.getItemCount(fuelslot) > 1
  59.         turtle.turnRight()
  60.         turtle.turnRight()
  61.     end
  62. end
  63.  
  64.  
  65.  
  66. function refuel()
  67.     if turtle.getFuelLevel() < 800 then
  68.         turtle.select(fuelslot)
  69.         repeat
  70.             turtle.refuel(fuelslot)
  71.             sleep(0.5)
  72.         until turtle.getFuelLevel() > 1600
  73.         turtle.select(3)
  74.     end
  75. end
  76.  
  77.  
  78.  
  79. -- torches
  80.  
  81.  
  82.  
  83. function torchesslotcheck()
  84.     if turtle.getItemCount(torchslot) < 1 then
  85.         turtle.select(torchslot)
  86.         turtle.turnLeft()
  87.         turtle.turnLeft()
  88.         turtle.up()
  89.         print("put torches in the chest!")
  90.         repeat
  91.             turtle.suck()
  92.         until turtle.getItemCount(torchslot) > 1
  93.         turtle.down()
  94.         turtle.turnRight()
  95.         turtle.turnRight()
  96.     end
  97. end
  98.  
  99.  
  100.  
  101. function digBlock()
  102.     repeat
  103.         turtle.dig()
  104.            
  105.     until not turtle.detect() == true
  106.     repeat
  107.         turtle.digUp()
  108.        
  109.     until not turtle.detect() == true
  110.     repeat
  111.         turtle.digDown()
  112.        
  113.     until not turtle.detect() == true
  114. end
  115.  
  116.  
  117.  
  118. function check()
  119.     turtle.select(1)
  120.     turtle.getItemCount(16)
  121.     if turtle.getItemCount(16) > 0 then
  122.     print("gotte go clean my inventory!")  
  123.         turtle.turnLeft()
  124.         turtle.turnLeft()
  125.         xx = x
  126.         zz = z
  127.         yy = y
  128. --go home
  129.         if x ~= 0 then
  130.         repeat
  131.             turtle.forward()
  132.             x = x - 1
  133.             sleep(0.5)
  134.             print("x:" .. x)   
  135.             print("y:" .. y)
  136.             print("z:" .. z)
  137.             print("xx:" .. xx) 
  138.             print("yy:" .. yy)
  139.             print("zz:" .. zz)
  140.         until x == 0
  141.         turtle.turnLeft()
  142.         end
  143.         if y ~= 0 then
  144.         repeat
  145.             turtle.forward()
  146.             y = y - 1
  147.             sleep(0.5)
  148.             print("x:" .. x)   
  149.             print("y:" .. y)
  150.             print("z:" .. z)
  151.             print("xx:" .. xx) 
  152.             print("yy:" .. yy)
  153.             print("zz:" .. zz) 
  154.         until y == 0
  155.         end
  156.         if z ~= 0 then
  157.         repeat
  158.             turtle.up()
  159.             z = z - 1
  160.             sleep(0.5)
  161.             print("x:" .. x)   
  162.             print("y:" .. y)
  163.             print("z:" .. z)
  164.             print("xx:" .. xx) 
  165.             print("yy:" .. yy)
  166.             print("zz:" .. zz) 
  167.         until z == 0
  168.         end
  169.  
  170. --Throw everything away
  171.  
  172.         repeat
  173.             turtle.select(i)
  174.             turtle.drop()
  175.             i = i + 1
  176.         until i == 17
  177.         turtle.turnRight()
  178.         turtle.turnRight()
  179.         Heighthowmany = 0
  180.         howmany = 0
  181.         widthhowmany = 0
  182.         i = 3
  183.         turtle.select(i)
  184.  
  185. --Go Back
  186.         if z ~= zz then
  187.         repeat
  188.             turtle.down()
  189.             z = z + 1
  190.             sleep(0.5)
  191.             print("x:" .. x)   
  192.             print("y:" .. y)
  193.             print("z:" .. z)
  194.             print("xx:" .. xx) 
  195.             print("yy:" .. yy)
  196.             print("zz:" .. zz)         
  197.         until z == zz
  198.         end
  199.         if y ~= yy then
  200.         repeat
  201.             turtle.forward()
  202.             y = y + 1
  203.             sleep(0.5)
  204.             print("x:" .. x)   
  205.             print("y:" .. y)
  206.             print("z:" .. z)
  207.             print("xx:" .. xx) 
  208.             print("yy:" .. yy)
  209.             print("zz:" .. zz)     
  210.         until y == yy
  211.         end
  212.         turtle.turnRight()
  213.         if x ~= xx then
  214.         repeat
  215.             turtle.forward()
  216.             x = x + 1
  217.             sleep(0.5)
  218.             print("x:" .. x)   
  219.             print("y:" .. y)
  220.             print("z:" .. z)
  221.             print("xx:" .. xx) 
  222.             print("yy:" .. yy)
  223.             print("zz:" .. zz)     
  224.         until x == xx
  225.         end
  226.  
  227.         else
  228.  
  229.         print("Nothing to clean")  
  230.  
  231.     end
  232. end
  233.  
  234. function status()
  235.     print("********************")
  236.     print("fuellevel:" .. turtle.getFuelLevel())
  237.     print("xLength:" .. xLength)
  238.     print("down:" .. down)
  239.     print("Height:" .. Height)
  240.     print("Length:" .. Length)
  241.     print("Width" .. Width)
  242.     print("********************")
  243.  
  244. end
  245.  
  246.  
  247.  
  248.  
  249. function forward()
  250.     xLength = Length
  251.     repeat
  252.         status()
  253.         digBlock()
  254.         turtle.forward()
  255.         turtle.digUp()
  256.         turtle.digDown()
  257.         xLength = xLength - 1
  258.         x = x + 1
  259.         check()
  260.  
  261.     until xLength == 0
  262.  
  263.     xLength = Length
  264.     turtle.turnRight()
  265.     turtle.turnRight()
  266.     repeat
  267.         status()
  268.         turtle.forward()
  269.         xLength = xLength - 1
  270.         x = x - 1
  271.     until xLength == 0
  272.  
  273.     Width = Width - 1
  274.        
  275.     if Width > 0 then
  276.         turtle.turnRight()
  277.         turtle.dig()
  278.         turtle.forward()
  279.         turtle.turnRight()
  280.         xWidth = xWidth + 1
  281.         y = y + 1
  282.     else
  283.         turtle.turnLeft()
  284.         repeat
  285.             status()
  286.             turtle.forward()
  287.             xWidth = xWidth -1
  288.         until xWidth == 0
  289.         y = 0
  290.     end
  291. end
  292.  
  293.  
  294. --go
  295.  
  296. print("Starting..")
  297.  
  298. fuelslotcheck()
  299. refuel()
  300. torchesslotcheck()
  301.  
  302. print("First Steps")
  303.  
  304.     turtle.digDown()
  305.     turtle.down()
  306.     z = z + 1
  307.     down = down + 1
  308.     Length = Length - 1
  309. repeat 
  310.     repeat
  311.         status()
  312.         forward()
  313.         refuel()
  314.     until Width == 0
  315.         turtle.turnLeft()
  316.         turtle.digDown()
  317.         turtle.down()
  318.         down = down + 1
  319.         z = z + 1
  320.         turtle.digDown()
  321.         turtle.down()
  322.         down = down + 1
  323.         z = z + 1
  324.         turtle.digDown()
  325.         turtle.down()
  326.         down = down + 1
  327.         z = z + 1
  328.         Width = Length
  329.         Width = Width + 1
  330.         Height = Height - 1
  331. until Height == 0
  332.  
  333. print("Done going down. Let's go up!")
  334.  
  335. if Height == 0 then
  336.     repeat
  337.         status()
  338.         turtle.up()
  339.         down = down - 1
  340.     until down == 0
  341.         z = 0d
  342. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement