View difference between Paste ID: LGupmN0y and Ee5bsu6C
SHOW: | | - or go back to the newest paste.
1-
robot = require("robot")
1+
robot = require("robot")
2-
side = 0
2+
side = 0
3-
side1 = 0
3+
side1 = 0
4-
4+
5-
function column(_height)
5+
function column(_height)
6-
  for i = 0, _height-2 do
6+
  for i = 0, _height-2 do
7-
    if side1 == 0 then
7+
    if side1 == 0 then
8-
      robot.swingUp()
8+
      robot.swingUp()
9-
      robot.up()
9+
      robot.up()
10-
    else
10+
    else
11-
      robot.swingDown()
11+
      robot.swingDown()
12-
      robot.down()
12+
      robot.down()
13-
    end
13+
    end
14-
  end
14+
  end
15-
15+
16-
  if side1 == 0 then
16+
  if side1 == 0 then
17-
    side1 = 1
17+
    side1 = 1
18-
  else
18+
  else
19-
    side1 = 0
19+
    side1 = 0
20-
  end
20+
  end
21-
end
21+
end
22-
22+
23-
function slice(_wight, _height)
23+
function slice(_wight, _height)
24-
  if side == 0 then
24+
  if side == 0 then
25-
    robot.turnLeft()
25+
    robot.turnLeft()
26-
  else
26+
  else
27-
    robot.turnRight()
27+
    robot.turnRight()
28-
  end
28+
  end
29-
  for i = 0, _wight-2 do
29+
  for i = 0, _wight-2 do
30-
    column(_height)
30+
    column(_height)
31-
    robot.swing()
31+
    robot.swing()
32-
    robot.forward()
32+
    robot.forward()
33-
  end
33+
  end
34-
  column(_height)
34+
  column(_height)
35-
  if side == 0 then
35+
  if side == 0 then
36-
    robot.turnRight()
36+
    robot.turnRight()
37-
    side = 1
37+
    side = 1
38-
  else
38+
  else
39-
    robot.turnLeft()
39+
    robot.turnLeft()
40-
    side = 0
40+
    side = 0
41-
  end
41+
  end
42-
end
42+
end
43-
43+
44-
function torch()
44+
function torch()
45-
  robot.turnAround()
45+
  robot.turnAround()
46-
  robot.place()
46+
  robot.place()
47-
  robot.turnAround()
47+
  robot.turnAround()
48-
end
48+
end
49-
49+
50-
function tonnel(_wight, _height, _depth)
50+
function tonnel(_wight, _height, _depth)
51-
  for i = 0, _depth-1 do
51+
  for i = 0, _depth-1 do
52-
    if i % 14 == 0 then
52+
    if i % 14 == 0 then
53-
      torch()
53+
      torch()
54-
    end
54+
    end
55-
    robot.swing()
55+
    robot.swing()
56-
    robot.forward()
56+
    robot.forward()
57-
    slice(_wight, _height)
57+
    slice(_wight, _height)
58-
  end
58+
  end
59-
  if side == 1 then
59+
  if side == 1 then
60-
    robot.turnRight()
60+
    robot.turnRight()
61-
    for i = 0, _wight-2 do robot.forward() end
61+
    for i = 0, _wight-2 do robot.forward() end
62-
    robot.turnLeft()
62+
    robot.turnLeft()
63-
  end
63+
  end
64-
  if side1 == 1 then
64+
  if side1 == 1 then
65-
    for i = 0, _height-2 do robot.down() end
65+
    for i = 0, _height-2 do robot.down() end
66-
  end
66+
  end
67-
end
67+
end
68-
68+
69-
function back(_depth)
69+
function back(_depth)
70-
  robot.turnAround()
70+
  robot.turnAround()
71-
  for i = 0, _depth-1 do
71+
  for i = 0, _depth-1 do
72-
    robot.forward()
72+
    robot.forward()
73-
  end
73+
  end
74-
  robot.turnAround()
74+
  robot.turnAround()
75-
end
75+
end
76-
76+
77-
print("Hello, master!")
77+
print("Hello, master!")
78-
print("Enter the wight:")
78+
print("Enter the wight:")
79-
wight = io.read()
79+
wight = io.read()
80-
print("Enter the height:")
80+
print("Enter the height:")
81-
height = io.read()
81+
height = io.read()
82-
print("Enter the depth:")
82+
print("Enter the depth:")
83-
depth = io.read()
83+
depth = io.read()
84-
print("Should I go back? [y/n]")
84+
print("Should I go back? [y/n]")
85-
back_ans = io.read()
85+
back_ans = io.read()
86-
86+
87-
print("Working...")
87+
print("Working...")
88-
tonnel(wight, height, depth, side, side1)
88+
tonnel(wight, height, depth, side, side1)
89-
if back_ans == "y" then
89+
if back_ans == "y" then
90-
  back(depth)
90+
  back(depth)
91-
end  
91+
end  
92
print("Done!")