Advertisement
jamawie

SmoothRoom

Oct 31st, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.70 KB | None | 0 0
  1. local component = require("component")
  2. local robot     = require("robot")
  3.  
  4. local term      = require("term")
  5.  
  6.  
  7. term.clear()
  8. term.setCursor(1,1)
  9. term.write("wie weit nach vorne?\nvorne: ")
  10. local front = tonumber(term.read())
  11. term.write("wie weit nach rechts?\nrechts: ")
  12. local side = tonumber(term.read())
  13. term.write("wie hoch?\nhöhe: ")
  14. local height = tonumber(term.read())
  15.  
  16. local slot = 1
  17.  
  18. function reload()
  19.   if slot ~= 15 then
  20.     slot = slot+1
  21.   else
  22.     error("Keine Blöcke mehr vorhanden!")
  23.   end
  24.   robot.select(slot)
  25. end
  26.  
  27. function check(up, down)
  28.   if down == true then
  29.     if robot.compareDown(16) == false then
  30.       robot.swingDown()
  31.       if robot.space() == 64 then
  32.         reload()
  33.       end
  34.       robot.placeDown()
  35.     end
  36.   end
  37.   if up == true then
  38.     if robot.compareUp(16) == false then
  39.       robot.swingUp()
  40.       if robot.space() == 64 then
  41.         reload()
  42.       end
  43.       robot.placeUp()
  44.     end
  45.   end
  46.  
  47.   _,str = robot.detect()
  48.   if str ~= "air" then
  49.     robot.swing()
  50.   end
  51. end
  52.  
  53. local direction = "right"
  54. for h=0,height do
  55.   if h==height then up = true else up = false end
  56.   if h==0 then down = true else down = false end
  57.   for y=0,side do
  58.     for x=0,front do    
  59.       check(up,down)
  60.       robot.forward()
  61.     end
  62.     if direction == "right" then
  63.       robot.turnRight()
  64.       if y~=side then
  65.         check(up,down)
  66.         robot.forward()
  67.       end
  68.       robot.turnRight()
  69.       direction = "left"
  70.     else
  71.       robot.turnLeft()
  72.       if y~=side then
  73.         check(up,down)
  74.         robot.forward()
  75.       end
  76.       robot.turnLeft()
  77.       direction = "right"
  78.     end
  79.   end
  80.   robot.swingUp()
  81.   robot.up()
  82.   if direction == "right" then
  83.     direction = "left"
  84.   else
  85.     direction = "right"
  86.   end
  87. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement