Advertisement
Guest User

pentacubed.lua

a guest
Feb 20th, 2020
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.53 KB | None | 0 0
  1. --pentacubed
  2.  
  3. local robot = require("robot")
  4.  
  5. offset = 10
  6. size = 5
  7.  
  8. --functions
  9. function gotocorner (r)
  10.   for i = 1,r,1
  11.   do
  12.     robot.forward()
  13.   end
  14.     robot.turnRight()
  15.   for i = 1,r,1
  16.   do
  17.     robot.forward()
  18.   end
  19.   robot.turnRight()
  20. end
  21.  
  22. function makeplane (size)
  23.   local spiral = size - 1
  24.   while spiral > 0
  25.   do
  26.     for side = 1,4,1
  27.     do
  28.       for i = 1,spiral,1
  29.       do
  30.         robot.placeDown()
  31.         if i < spiral then robot.forward() end
  32.       end
  33.       if side < 4 then robot.forward() end
  34.       robot.turnRight()  
  35.     end
  36.     robot.forward()
  37.     spiral = spiral - 2
  38.   end
  39.   robot.placeDown()
  40. end
  41.  
  42. function makewalls (size)
  43.   for side = 1,4,1
  44.   do
  45.     for i = 1,size,1
  46.     do
  47.       robot.placeDown()
  48.       if i < size then robot.forward() end
  49.     end
  50.     robot.turnRight()
  51.   end
  52. end
  53.  
  54. --move to field
  55.  
  56. for i = 1,offset,1
  57. do
  58.   robot.forward()
  59. end
  60.  
  61. --go to starting corner for floor
  62. gotocorner(size / 2)
  63.  
  64. --build floor
  65. robot.select(4)
  66. robot.up()
  67. makeplane(size)
  68.  
  69. --go to starting corner for walls
  70. gotocorner(size / 2)
  71.  
  72. --build walls
  73. for f = 1,size - 2,1
  74. do
  75.   robot.select(4+f)
  76.   robot.up()
  77.   makewalls(size)
  78.   if f == 2 then
  79.     for z = 1,2,1
  80.       do
  81.       robot.forward()
  82.     end
  83.     robot.turnRight()
  84.     for z = 1,2,1
  85.       do
  86.       robot.forward()
  87.     end
  88.     robot.select(14)
  89.     robot.placeDown()
  90.     robot.select(4+f)
  91.     for z = 1,2,1
  92.     do
  93.       robot.forward()
  94.     end
  95.     robot.turnRight()
  96.     for z = 1,2,1
  97.       do
  98.       robot.forward()
  99.     end
  100.     robot.turnRight()
  101.   end
  102. end
  103.  
  104. --build ceiling
  105. robot.up()
  106. robot.select(8)
  107. makeplane(size)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement