Advertisement
cragrim

MiningRigControl_personalmemo

Aug 12th, 2014
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.64 KB | None | 0 0
  1. --MiningRig control
  2. d = "right"
  3. failcount = 0
  4.  
  5. function dig()
  6.   rs.setBundledOutput(d,colors.orange)
  7.   os.sleep(8)
  8.   rs.setBundledOutput(d,0)
  9. end
  10.  
  11. function move()
  12.   rs.setBundledOutput(d,colors.magenta)
  13.   os.sleep(2)
  14.   rs.setBundledOutput(d,colors.lightBlue)
  15.   os.sleep(2)
  16.   rs.setBundledOutput(d,0)
  17. end
  18.  
  19. function breakBlocks()
  20.   rs.setBundledOutput(d,colors.white)
  21.   os.sleep(0.5)
  22.   rs.setBundledOutput(d,0)
  23.   os.sleep(0.5)
  24. end
  25.  
  26. function checkChest()
  27.   c = peripheral.wrap("top")
  28.   if c.getStackInSlot(1) == nil then
  29.     return false
  30.   else
  31.     return true
  32.   end    
  33. end
  34.  
  35.  
  36. while true do
  37. --for i=1,2 do
  38.  
  39.   if turtle.getFuelLevel() < 10 then
  40.     break
  41.   end
  42.  
  43.   --check if too far
  44.   if rs.getInput("right") == true then
  45.     turtle.back()
  46.     print("Move operation unsuccessful...")
  47.     os.sleep(1)
  48.     failcount = failcount + 1
  49.     --os.sleep(60)
  50.     --break
  51.   else
  52.     failcount = 0
  53.   end
  54.  
  55.   if failcount > 3 then
  56.     break
  57.   end
  58.  
  59.  
  60.   --place ender chest
  61.   turtle.placeUp()
  62.   if checkChest() == true then
  63.     breakBlocks()
  64.     print("Stuff in chest! Mining...")
  65.     --pickup ender chest
  66.     turtle.digUp()
  67.     dig()
  68.     breakBlocks()
  69.     move()
  70.     breakBlocks()
  71.    
  72.     if turtle.detect() == true then
  73.       turtle.dig()
  74.       turtle.select(2)
  75.       turtle.dropDown()
  76.       turtle.select(1)
  77.     end
  78.    
  79.     turtle.forward()  
  80.    
  81.     if turtle.detectUp() == true then
  82.       turtle.digUp()
  83.       turtle.select(2)
  84.       turtle.dropDown()
  85.       turtle.select(1)
  86.     end
  87.     os.sleep(1)
  88.            
  89.   else
  90.     print("Nothing in chest waiting...")
  91.     os.sleep(10)
  92.   end
  93.  
  94. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement