Advertisement
Guest User

Caller

a guest
Sep 24th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.75 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, Elev1R = rednet.receive("ElevatorFloor")
  7.   id, Elev2R = rednet.receive("ElevatorFloor2")
  8.  
  9.   if Elev1R > 0 then
  10.     Elev1 = Elev1R
  11.   end
  12.  
  13.   if Elev2R > 0 then
  14.     Elev2 = Elev2R
  15.   end
  16.  
  17.   if rs.getInput("front") == true then
  18.     Elev1D = math.abs(CurFloor - Elev1)
  19.     Elev2D = math.abs(CurFloor - Elev2)
  20.     if Elev1D < Elev2D then
  21.       rednet.broadcast(CurFloor, "ElevatorTarget")
  22.     else
  23.       rednet.broadcast(CurFloor, "ElevatorTarget2")
  24.     end
  25.     os.sleep(2)
  26.   end
  27.  
  28.   monitor.clear()  
  29.   monitor.setCursorPos(1,1)
  30.   monitor.setTextScale(2.5)
  31.   monitor.write(Elev1 .. "|" .. Elev2)
  32.   os.sleep(0.10)
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement