View difference between Paste ID: aHAuUtqC and uVvuTvDZ
SHOW: | | - or go back to the newest paste.
1-
robot = require("robot")
1+
robot = require("robot")
2-
2+
3-
function main()
3+
function main()
4-
  while true do
4+
  while true do
5-
    local _, isWood = robot.detect()
5+
    local _, isWood = robot.detect()
6-
    if isWood == "solid" then
6+
    if isWood == "solid" then
7-
      jack()
7+
      jack()
8-
      plant()
8+
      plant()
9-
    end
9+
    end
10-
    os.sleep(30)
10+
    os.sleep(30)
11-
    suck()
11+
    suck()
12-
  end
12+
  end
13-
end
13+
end
14-
14+
15-
function jack()
15+
function jack()
16-
  while robot.detect() do
16+
  while robot.detect() do
17-
    robot.swing()
17+
    robot.swing()
18-
    robot.swingUp()
18+
    robot.swingUp()
19-
    robot.up()
19+
    robot.up()
20-
  end
20+
  end
21-
  while not robot.detectDown() do
21+
  while not robot.detectDown() do
22-
    robot.down()
22+
    robot.down()
23-
  end
23+
  end
24-
end
24+
end
25-
25+
26-
function plant()
26+
function plant()
27-
  robot.place()
27+
  robot.place()
28-
end
28+
end
29-
29+
30-
function suck()
30+
function suck()
31-
  robot.turnRight()
31+
  robot.turnRight()
32-
  for i = 0, 3 do
32+
  for i = 0, 3 do
33-
    robot.forward()
33+
    robot.forward()
34-
    robot.turnLeft()
34+
    robot.turnLeft()
35-
    robot.forward()
35+
    robot.forward()
36-
    rotate()
36+
    rotate()
37-
  end
37+
  end
38-
  robot.turnLeft()
38+
  robot.turnLeft()
39-
end
39+
end
40-
40+
41-
function rotate()
41+
function rotate()
42-
  for i = 0, 3 do
42+
  for i = 0, 3 do
43-
    robot.suck()
43+
    robot.suck()
44-
    robot.turnRight()
44+
    robot.turnRight()
45-
  end
45+
  end
46-
end
46+
end
47-
47+
48
main()