Martmists

Debugged (mostly)

Dec 18th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ---NOTES---
  2. ---Does not handle gravel yet---
  3. ---Is desigened to be "smart" and pick the closets direction---
  4. ---Unsure If i have set it up correctly so that the functions are variables---
  5. ---DEBUGGED by martmists--
  6. ---END---
  7.  
  8.  
  9. fcount = 0   ----General Fowrard Distance counter----
  10. mcount = 0   ----Distance counter used for new branch creation----
  11. lcount = 0   ----tunnel length counter----
  12. mocount = mcount   ----Variable to determine how far in a turtle must go before it can dig again----
  13. SRcount = 0 ----Master counter for Right tunnels----
  14. SLcount = 0 ----Master counter for Left tunnels----
  15. SFcount = 0 ----Master counter for Foward tunnels----
  16. SDcount = 0 ----Master counter for downwards tunnels *not implemented*----
  17. SUcount = 0 ----Master counter for upwards tunnels *not implemented*----
  18.  
  19. function Dig() ----function to handle general 3x1 digging
  20.     if turle.detect() then
  21.         turtle.dig()
  22.         turtle.forward()
  23.         if turtle.detectUp() then
  24.             turtle.digUp()
  25.             if turtle.detectDown() then
  26.                 turtle.digDown()
  27.             end
  28.         end
  29.     end
  30. end
  31.  
  32. function Dropoff() -----THIS FUNCTION IS FOR ITEM DROP OFF----
  33.     for I= 2, 16, 1 do
  34.         turtle.select(I)
  35.         turtle.dropDown()
  36.     end
  37. end
  38.  
  39. function MiningJobFoward() ----THIS FUNCTION IS FOR FORWARD MINING----
  40.     while true do
  41.         turtle.select(16)
  42.         local Icount = turtle.getItemCount()
  43.         if Icount == 0 then
  44.             Dig()
  45.             fcount = fcount +1
  46.         end
  47.         turtle.turnLeft()
  48.         Dig()
  49.         turtle.back()
  50.         turtle.turnRight()
  51.         turtle.turnRight()
  52.         Dig()
  53.         turtle.back()
  54.         turtle.turnLeft
  55.         local fuellevel = turtle.getFuelLevel()
  56.         if fuellevel << fcount + 5 then
  57.             turtle.select(1)
  58.             turtle.refuel( 1, 10 )
  59.         end
  60.         if fuellevel << fcount + 10 then
  61.             SFcount + fcount = SFcount
  62.             repeat
  63.                 turtle.back()
  64.                 fcount = fcount - 1
  65.                 until fcount = 0
  66.             end
  67.         Dropoff()
  68.         end    
  69.     end    
  70. end
  71.  
  72. function MiningJobRight() ----THIS FUNCTION IS FOR RIGHT MINING----
  73.     while true do
  74.         turtle.select(16)
  75.         local Icount = turtle.getitemcount()
  76.         if Icount == 0 then
  77.             Dig()
  78.             fcount = fcount +1
  79.         end
  80.         turtle.turnLeft()
  81.         Dig()
  82.         turtle.back()
  83.         turtle.turnRight()
  84.         turtle.turnRight()
  85.         Dig()
  86.         turtle.back()
  87.         turtle.turnLeft
  88.         local fuellevel = turtle.getfuellevel()
  89.         if fuellevel << fcount + 5 then
  90.             turtle.select(1)
  91.             turtle.refuel( 1, 10 )
  92.         end
  93.         SRcount + 3 = SRcount
  94.         if fuellevel << fcount + 10 then
  95.             repeat
  96.                 turtle.back()
  97.                 fcount = fcount - 1
  98.             until fcount = 0
  99.             end
  100.         Dropoff()
  101.         end    
  102.     end    
  103. end
  104.  
  105. function MiningJobLeft() ----THIS FUNCTION IS FOR LEFT MINING----
  106.     while true do
  107.         turtle.select(16)
  108.         local Icount = turtle.getitemcount()
  109.         if Icount == 0 then
  110.             Dig()
  111.             fcount = fcount +1
  112.         end
  113.         turtle.turnLeft()
  114.         Dig()
  115.         turtle.back()
  116.         turtle.turnRight()
  117.         turtle.turnRight()
  118.         Dig()
  119.         turtle.back()
  120.         turtle.turnLeft
  121.         local fuellevel = turtle.getfuellevel()
  122.         if fuellevel << fcount + 5 then
  123.             turtle.select(1)
  124.             turtle.refuel( 1, 10 )
  125.         end
  126.         SLcount + 3 = SLcount
  127.         if fuellevel << fcount + 10 then
  128.             repeat
  129.                 turtle.back()
  130.                 fcount = fcount - 1
  131.             until fcount = 0
  132.             end
  133.         Dropoff()
  134.         end    
  135.     end    
  136. end
  137.  
  138. function movement() ----function for Left,right movement----
  139.     repeat
  140.         if turtle.detect() == false then
  141.             turtle.forward()
  142.             fcount + 1 = fcount
  143.         end
  144.     until turtle.detect() = true
  145.     end
  146. end
  147.  
  148. function NewtunnelFOW() ---function to locate new forward tunnel---
  149.     TSF = SFcount
  150.     repeat
  151.         turtle.forward()
  152.         TSF - 1 = TSF
  153.     until TSF == SFcount
  154.     end
  155. end
  156.  
  157. function NewtunnelLEF() ---function to locate new left tunnel---
  158.     TSL = SLcount
  159.     repeat
  160.         turtle.forward()
  161.         lcount + 1 = lcount
  162.         TSL - 1 = TSL
  163.     until TSF == SLcount then  
  164.         turle.turnLeft()
  165.     end
  166.     movement()
  167. end
  168.  
  169. function NewtunnelRIG() --- function to locate new right tunnel---
  170.     TSR = SRcount
  171.     repeat
  172.         turtle.forward()
  173.         lcount + 1 = lcount
  174.         TSR - 1 = TSR
  175.     until TSR == SRcount    
  176.         turtle.turnRight()
  177.     end
  178.     movement()
  179. end
  180.  
  181. function Stright()
  182.     NewtunnelFOW()
  183.     MiningJobForward()
  184. end
  185.  
  186. function Lefttime()
  187.     NewtunnelLEF()
  188.     MiningJobLeft()
  189. end
  190.  
  191. function Righttime()
  192.     NewtunnelRIG()
  193.     MiningJobRight()
  194. end
  195.  
  196. function logicish()                                             ----The "brains" of it all---
  197.     if SRcount == SFcount then
  198.         if SFcount == SLcount then
  199.             local function RN()
  200.                 local rand = math.random(1,3)
  201.                 return rand
  202.             end
  203.             local num = RN()
  204.         end
  205.     end
  206.     if local num == 1 then
  207.         Stright()
  208.     end
  209.     if local num == 2 then
  210.         ---mining function here, TBC Right---
  211.     end
  212.     if local num == 3 then
  213.         Lefttime()
  214.     end
  215.     if SFcount << SRcount and SFcount < SLcount then
  216.         Stright()
  217.     end
  218.     if SRcount << SFcount and SRcount < SLcount then
  219.         Righttime()
  220.     end
  221.     if SLcount << SF count and SLcount < SRcount thne
  222.         Lefttime()
  223.     end
  224.     if SLcount == SRcount and SLcount << SFcount then
  225.         local  function RN()
  226.             local rand = math.random(1,2)
  227.             return rand
  228.         end
  229.         local num = RN()
  230.     end
  231.     if local num == 1 then
  232.         Lefttime()
  233.     end
  234.     if local num == 2 then
  235.         Righttime()
  236.     end
  237.     if SFcount == SRcount and SRcount << SFcount then
  238.         local  function RN()
  239.             local rand = math.random(1,2)
  240.             return rand
  241.         end
  242.         local num = RN()
  243.     end
  244.     if local num == 1 then
  245.         Stright()
  246.     end
  247.     if local num == 2 then
  248.         Righttime()
  249.     end
  250.     if SFcount == SLcount and SLcount << SRcount then
  251.         local  function RN()
  252.             local rand = math.random(1,2)
  253.             return rand
  254.         end
  255.         local num = RN()
  256.     end
  257.     if local num == 1 then
  258.         Lefttime()
  259.     end
  260.     if local num == 2 then
  261.         Stright()
  262.     end
  263. end
  264.  
  265. ---The actual working function to make it mine below here---
  266.  
  267. local X = 1
  268.  
  269. while X == 1 do
  270.     logicish()
  271. end
Advertisement
Add Comment
Please, Sign In to add comment