Advertisement
Guest User

Caller

a guest
Mar 24th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.61 KB | None | 0 0
  1. rednet.open("back")
  2. local monitor = peripheral.wrap("top")
  3. local CurFloor = 9
  4. monitor.clear()
  5. while true do
  6.   id, Elev1 = rednet.receive("ElevatorFloor")
  7.   id, Elev2 = rednet.receive("ElevatorFloor2")
  8.   if rs.getInput("front") == true then
  9.     Elev1D = math.abs(CurFloor - Elev1)
  10.     Elev2D = math.abs(CurFloor - Elev2)
  11.     if Elev1D < Elev2D then
  12.       rednet.broadcast(CurFloor, "ElevatorTarget")
  13.     else
  14.       rednet.broadcast(CurFloor, "ElevatorTarget2")
  15.     end
  16.     os.sleep(2)
  17.   end
  18.   monitor.setCursorPos(1,1)
  19.   monitor.setTextScale(2.5)
  20.   monitor.write(Elev1 .. "|" .. Elev2)
  21.   os.sleep(0.15)
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement