Advertisement
DevilTvLP

openComputersRoom

Jun 23rd, 2018 (edited)
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.03 KB | None | 0 0
  1. local robot = require("robot")
  2. local term = require("term")
  3. local math = require("math")
  4.  
  5. function doX(x, f)
  6.   i = 0
  7.   while i<x do
  8.     f()
  9.     i = i+1
  10.   end
  11. end
  12.  
  13. function forward()
  14.   robot.swing()
  15.   while not robot.forward() do
  16.     robot.swing()
  17.     os.sleep(0.2)
  18.   end
  19. end
  20.  
  21. print("Länge: ")
  22. local length = tonumber(term.read())-1
  23. print("Breite: ")
  24. local width = tonumber(term.read())
  25. print("Höhe: ")
  26. local height = tonumber(term.read())
  27.  
  28. local s1 = true
  29.  
  30. for y=1,height,1 do
  31.   for z=1,width,1 do
  32.     for x=1,length,1 do
  33.       forward()
  34.     end
  35.     if z~=width then
  36.       if s1 then
  37.         robot.turnRight()
  38.         forward()
  39.         robot.turnRight()
  40.       else
  41.         robot.turnLeft()
  42.         forward()
  43.         robot.turnLeft()
  44.       end
  45.       s1 = not s1
  46.     end
  47.   end
  48.   if y~=height then
  49.     if math.fmod(width, 2)==0 then
  50.       for i=1,length,1 do robot.back() end
  51.     else
  52.       robot.turnLeft()
  53.       robot.turnLeft()
  54.     end
  55.     robot.swingDown()
  56.     robot.down()
  57.     s1 = true
  58.   end
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement