-- Test local robot = require 'robot' local computer = require 'computer' local m = robot.inventorySize() -- To check if robot is full. local j = 0 -- Is for count of OOC local t = 0 -- Is for count for T local p = 0 -- Is for count of EM local f = 0 -- For check if side needs put back after chest. local u = 0 -- For check if ceiling needs put back after chest. local l = 0 -- For tunnel length. local d = 0 -- For check if floor needs put back after chest. function OOC() -- Check to see if its low on out of cobblestone. j=5 robot.select(1) while robot.count() <=5 do if robot.compare(j) == true then robot.select(j) robot.transferTo(1) robot.select(1) end if j >= m then print ("Low on cobblestone.") os.exit() end j=j+1 end end function EM() -- When full this empties contents of robot. while robot.detectUp() do robot.swingUp() os.sleep(0.4) end robot.up() while robot.detect() do robot.swing() os.sleep(0.4) end while robot.detectDown() do robot.swing() os.sleep(0.4) end robot.down() while robot.detect() do robot.swing() os.sleep(0.4) end robot.select(4) robot.place() p=5 while p <= m do robot.select(p) robot.drop() p=p+1 end robot.select(4) D() robot.suck() if f == 1 then robot.select(1) robot.up() robot.place() robot.down() robot.place() end if u == 1 then robot.select(1) robot.placeUp() end if d == 1 then robot.select(1) robot.placeDown() end end function CF() robot.select(m) if robot.count() >= 1 then print ("Robot is full, unloading.") EM() end robot.select(1) end function DU() while robot.detectUp() do robot.swingUp() CF() os.sleep(0.4) end end function CD() robot.select(1) OOC() if robot.compareDown() ~= true then robot.select(2) if robot.compareDown() ~= true then robot.swingDown() CF() robot.select(1) robot.placeDown() end end end function D() while robot.detect() do robot.swing() CF() os.sleep(0.4) end end function C() robot.select(1) OOC() if robot.compare() ~= true then robot.select(2) if robot.compare() ~= true then D() CF() robot.select(1) robot.place() end end end function CU() robot.select(1) OOC() if robot.compareUp() ~= true then robot.select(2) if robot.compareUp() ~= true then robot.swingUp() CF() robot.select(1) os.sleep(0.4) robot.placeUp() end end end function DD() robot.swingDown() CF() end function T() t=0 D() CF() robot.forward() D() CF() robot.back() robot.select(3) robot.place() robot.select(1) end print ("How long of a tunnel? ") local l = io.read() for a =1,l do t=t+1 if computer.energy() <=10 then print ("Low on energy.") os.exit() end d=1 D() robot.forward() CD() DU() robot.turnLeft() D() f=1 robot.forward() CD() C() DU() robot.up() d=0 if t == 5 then T() else C() end DD() DU() robot.up() C() DU() robot.up() u=1 C() CU() robot.turnAround() f=0 D() robot.forward() CU() DD() D() robot.forward() f=1 CU() C() DD() robot.down() u=0 C() DD() robot.down() C() DD() robot.down() d=1 C() CD() robot.turnAround() f=0 D() robot.forward() D() robot.turnRight() end