Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- robot = require("robot")
- side = 0
- side1 = 0
- function column(_height)
- for i = 0, _height-2 do
- if side1 == 0 then
- robot.swingUp()
- robot.up()
- else
- robot.swingDown()
- robot.down()
- end
- end
- if side1 == 0 then
- side1 = 1
- else
- side1 = 0
- end
- end
- function slice(_wight, _height)
- if side == 0 then
- robot.turnLeft()
- else
- robot.turnRight()
- end
- for i = 0, _wight-2 do
- column(_height)
- robot.swing()
- robot.forward()
- end
- column(_height)
- if side == 0 then
- robot.turnRight()
- side = 1
- else
- robot.turnLeft()
- side = 0
- end
- end
- function torch()
- robot.turnAround()
- robot.place()
- robot.turnAround()
- end
- function tonnel(_wight, _height, _depth)
- for i = 0, _depth-1 do
- if i % 14 == 0 then
- torch()
- end
- robot.swing()
- robot.forward()
- slice(_wight, _height)
- end
- if side == 1 then
- robot.turnRight()
- for i = 0, _wight-2 do robot.forward() end
- robot.turnLeft()
- end
- if side1 == 1 then
- for i = 0, _height-2 do robot.down() end
- end
- end
- function back(_depth)
- robot.turnAround()
- for i = 0, _depth-1 do
- robot.forward()
- end
- robot.turnAround()
- end
- print("Hello, master!")
- print("Enter the wight:")
- wight = io.read()
- print("Enter the height:")
- height = io.read()
- print("Enter the depth:")
- depth = io.read()
- print("Should I go back? [y/n]")
- back_ans = io.read()
- print("Working...")
- tonnel(wight, height, depth, side, side1)
- if back_ans == "y" then
- back(depth)
- end
- print("Done!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement