Guest User

IC2 Miner Drill Swap Script

a guest
Mar 21st, 2013
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.13 KB | None | 0 0
  1. -- shell.run("drill_swap")
  2. print( os.getComputerLabel() )
  3.  
  4. local running = false
  5.  
  6. while true do
  7.     if rs.getInput("back") then
  8.         rs.setOutput("left", true)
  9.         rs.setOutput("bottom", true)
  10.         term.clear()
  11.         term.setCursorPos(1,1)
  12.         print("Drilling On")
  13.         sleep(2)  -- Delay to make sure rig finished moving
  14.         turtle.drop() -- place drill
  15.         local lastSeen = 0
  16.         while rs.getInput("back") do
  17.                 local itemCount = 0
  18.                 for n=1,16 do
  19.                     itemCount = itemCount + turtle.getItemCount(n)
  20.                     sleep(.1)
  21.                 end
  22.                 if itemCount > 0 then
  23.                     rs.setOutput("top", true)
  24.                     lastSeen = 0
  25.                     rs.setOutput("left", true)
  26.                     rs.setOutput("bottom", true)
  27.                 else
  28.                     rs.setOutput("top", false)
  29.                     lastSeen = lastSeen + 1
  30.                 end        
  31.                 if lastSeen > 6 then
  32.                     rs.setOutput("left", false)
  33.                     rs.setOutput("bottom", false)
  34.                 end
  35.                 sleep(10) -- hold if out of power/storage
  36.                 rs.setOutput("top", false)
  37.                 running = true
  38.         end
  39.     else
  40.         term.clear()
  41.         term.setCursorPos(1,1) 
  42.         print("Drilling Off")
  43.         if running then
  44.             turtle.transferTo(16)
  45.             turtle.suck()
  46.         end
  47.         os.pullEvent("redstone")
  48.     end
  49. end
Advertisement
Add Comment
Please, Sign In to add comment