Advertisement
Guest User

bridge.lua

a guest
Jan 17th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.75 KB | None | 0 0
  1. local component = require("component")
  2. local robot = component.proxy(component.list("robot")() or error("No robot component"))
  3. local sides = require("sides")
  4.  
  5. local length = 10
  6. local width = 3
  7.  
  8. function move(right)
  9.   robot.turn(right)
  10.   robot.move(sides.front)
  11.   robot.turn(not right)
  12.   robot.move(sides.back)
  13. end
  14.  
  15. function select(direction)
  16.   while not robot.compare(sides.down) do
  17.     robot.select(robot.select() % robot.inventorySize() + direction)
  18.   end
  19. end
  20.  
  21. function start()
  22.   right = true
  23.   direction = 1
  24.   for y = 1, length-1 do
  25.     for x = 1, width do
  26.       select(direction)
  27.       robot.move(sides.front)
  28.       robot.place(sides.down)
  29.  
  30.       if x < width then
  31.         move(right)
  32.       end
  33.     end
  34.     right = not right
  35.     direction = -direction
  36.   end
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement