Advertisement
Solomeister

lumberbot v0.1

Aug 6th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local robot = require("robot")
  2. local comp = require("computer")
  3. local component = require("component")
  4. local inv = component.inventory_controller
  5. local term = require("term")
  6. local sides = require("sides")
  7.  
  8. h = 0
  9.  
  10. function rechTool()
  11.   robot.select(2)
  12.   robot.turnRight()
  13.   robot.drop()
  14.   os.sleep(2)
  15.   robot.suck()
  16.   robot.turnLeft()
  17. end
  18.  
  19. function checkTool()
  20.   robot.select(2)
  21.   inv.equip()
  22.   dur = robot.durability()
  23.   inv.equip()
  24.   return dur
  25. end
  26.      
  27. function routine()
  28.   _, det = robot.detect()
  29.   if det == 'solid' then
  30.     robot.swing()
  31.     robot.use(1, true)
  32.     robot.use(1, true)
  33.     while robot.detectUp() == 0 do
  34.       robot.up()
  35.       h = h+1
  36.     end
  37.     for i = 1, 3 do
  38.       robot.up()
  39.       robot.swingUp()
  40.       h = h+1
  41.     end
  42.     for i =  1, h do
  43.       robot.down()
  44.     end
  45.     h = 0
  46.     robot.use(1, true)
  47.     robot.suckUp()
  48.   elseif det == 'passable' then
  49.     robot.select(2)
  50.     inv.equip()
  51.     for i = 1, 10 do
  52.       robot.use()
  53.     end
  54.     robot.select(2)
  55.     inv.equip()
  56.   else
  57.     robot.select(1)
  58.     robot.place()  
  59.   end
  60. end
  61.  
  62. function lumbMain()
  63.   b = 0
  64.   while robot.count(16) < 63 do
  65.     routine()
  66.     b = b + 1
  67.     if b == 100 then
  68.       if checkTool() == 0 then
  69.         break
  70.         rechTool()
  71.       end
  72.     b = 0
  73.     end
  74.   end
  75.   for i = 4, 16 do
  76.     robot.select(i)
  77.     robot.dropDown()
  78.   end
  79.   lumbMain()
  80. end
  81. lumbMain()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement