View difference between Paste ID: HAREs1MJ and c6KEKnrC
SHOW: | | - or go back to the newest paste.
1-
local robot = require("robot")
1+
local robot = require("robot")
2-
local comp = require("computer")
2+
local comp = require("computer")
3-
local component = require("component")
3+
local component = require("component")
4-
local inv = component.inventory_controller
4+
local inv = component.inventory_controller
5-
local term = require("term")
5+
local term = require("term")
6-
local sides = require("sides")
6+
local sides = require("sides")
7-
7+
8-
h = 0
8+
h = 0
9-
9+
10-
function rechTool()
10+
function rechTool()
11-
  robot.select(2)
11+
  robot.select(2)
12-
  robot.turnRight()
12+
  robot.turnRight()
13-
  robot.drop()
13+
  robot.drop()
14-
  os.sleep(2)
14+
  os.sleep(2)
15-
  robot.suck()
15+
  robot.suck()
16-
  robot.turnLeft()
16+
  robot.turnLeft()
17-
end
17+
end
18-
  
18+
  
19-
function checkTool()
19+
function checkTool()
20-
  robot.select(2)
20+
  robot.select(2)
21-
  inv.equip()
21+
  inv.equip()
22-
  dur = robot.durability()
22+
  dur = robot.durability()
23-
  inv.equip()
23+
  inv.equip()
24-
  return dur
24+
  return dur
25-
end
25+
end
26-
     
26+
     
27-
function routine() 
27+
function routine() 
28-
  _, det = robot.detect()
28+
  _, det = robot.detect()
29-
  if det == 'solid' then
29+
  if det == 'solid' then
30-
    robot.swing()
30+
    robot.swing()
31-
    robot.use(1, true)
31+
    robot.use(1, true)
32-
    robot.use(1, true)
32+
    robot.use(1, true)
33-
    while robot.detectUp() == 0 do
33+
    while robot.detectUp() == 0 do
34-
      robot.up()
34+
      robot.up()
35-
      h = h+1
35+
      h = h+1
36-
    end
36+
    end
37-
    for i = 1, 3 do
37+
    for i = 1, 3 do
38-
      robot.up()
38+
      robot.up()
39-
      robot.swingUp()
39+
      robot.swingUp()
40-
      h = h+1
40+
      h = h+1
41-
    end
41+
    end
42-
    for i =  1, h do
42+
    for i =  1, h do
43-
      robot.down()
43+
      robot.down()
44-
    end
44+
    end
45-
    h = 0
45+
    h = 0
46-
    robot.use(1, true)
46+
    robot.use(1, true)
47-
    robot.suckUp()
47+
    robot.suckUp()
48-
  elseif det == 'passable' then
48+
  elseif det == 'passable' then
49-
    robot.select(2)
49+
    robot.select(2)
50-
    inv.equip()
50+
    inv.equip()
51-
    for i = 1, 10 do
51+
    for i = 1, 10 do
52-
      robot.use()
52+
      robot.use()
53-
    end
53+
    end
54-
    robot.select(2)
54+
    robot.select(2)
55-
    inv.equip()
55+
    inv.equip()
56-
  else
56+
  else
57-
    robot.select(1)
57+
    robot.select(1)
58-
    robot.place()  
58+
    robot.place()  
59-
  end
59+
  end
60-
end
60+
end
61-
61+
62-
function lumbMain()
62+
function lumbMain()
63-
  b = 0
63+
  b = 0
64-
  while robot.count(16) < 63 do
64+
  while robot.count(16) < 63 do
65-
    routine()
65+
    routine()
66-
    b = b + 1
66+
    b = b + 1
67-
    if b == 100 then
67+
    if b == 100 then
68-
      if checkTool() == 0 then
68+
      if checkTool() == 0 then
69-
        break
69+
        break
70-
        rechTool()
70+
        rechTool()
71-
      end
71+
      end
72-
    b = 0
72+
    b = 0
73-
    end
73+
    end
74-
  end
74+
  end
75-
  for i = 4, 16 do
75+
  for i = 4, 16 do
76-
    robot.select(i)
76+
    robot.select(i)
77-
    robot.dropDown()
77+
    robot.dropDown()
78-
  end
78+
  end
79-
  lumbMain()
79+
  lumbMain()
80-
end
80+
end
81
lumbMain()