Advertisement
lpjakewolfskin

miner_final

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