View difference between Paste ID: 1kx99aUG and FzJjdQ00
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+
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() == false do
33+
    for i = 1, 4 do
34-
      robot.up()
34+
	  robot.swingUp()
35-
      h = h+1
35+
      robot.up()
36-
    end
36+
    end
37-
    for i = 1, 3 do
37+
    while robot.detectDown() == 0 do
38-
      robot.up()
38+
      robot.down()
39-
      robot.swingUp()
39+
    end
40-
      h = h+1
40+
    robot.use(1, true)
41-
    end
41+
    robot.suckUp()
42-
    for i =  1, h do
42+
  elseif det == 'passable' then
43-
      robot.down()
43+
    robot.select(2)
44-
    end
44+
    inv.equip()
45-
    h = 0
45+
    for i = 1, 10 do
46-
    robot.use(1, true)
46+
      robot.use()
47-
    robot.suckUp()
47+
    end
48-
  elseif det == 'passable' then
48+
    robot.select(2)
49-
    robot.select(2)
49+
    inv.equip()
50-
    inv.equip()
50+
  else
51-
    for i = 1, 10 do
51+
    robot.select(1)
52-
      robot.use()
52+
    robot.place()  
53-
    end
53+
  end
54-
    robot.select(2)
54+
end
55-
    inv.equip()
55+
56-
  else
56+
function lumbMain()
57-
    robot.select(1)
57+
  b = 0
58-
    robot.place()  
58+
  while robot.count(16) < 63 do
59-
  end
59+
    routine()
60-
end
60+
    robot.suckUp()
61-
61+
    b = b + 1
62-
function lumbMain()
62+
    if b == 100 then
63-
  b = 0
63+
      if checkTool() == 0 then
64-
  while robot.count(16) < 63 do
64+
        break
65-
    routine()
65+
        rechTool()
66-
    robot.suckUp()
66+
      end
67-
    b = b + 1
67+
    b = 0
68-
    if b == 100 then
68+
    end
69-
      if checkTool() == 0 then
69+
  end
70-
        break
70+
  for i = 4, 16 do
71-
        rechTool()
71+
    robot.select(i)
72-
      end
72+
    robot.dropDown()
73-
    b = 0
73+
  end
74-
    end
74+
  robot.select(1)
75-
  end
75+
  lumbMain()
76-
  for i = 4, 16 do
76+
end
77-
    robot.select(i)
77+