meuced

Ep. 23 API Modem - receive

May 7th, 2013
1,119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.78 KB | None | 0 0
  1. local mon = peripheral.wrap("right")
  2.  
  3. local modem = peripheral.wrap("bottom")
  4.  
  5. function gotoln()
  6.   local x, y = mon.getCursorPos()
  7.   if y1 == y then
  8.     mon.scroll(1)
  9.     mon.setCursorPos(1, y)
  10.   else
  11.     mon.setCursorPos(1, y+1)
  12.   end
  13. end
  14.  
  15. while true do
  16.   mon.clear()
  17.   term.clear()
  18.   message=""
  19.   print("Channel à écouter : ")
  20.   chanrec = tonumber(read())
  21.   modem.open(chanrec)
  22.   mon.write("On ecoute sur le channel : "..chanrec)
  23.   gotoln()
  24.   local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  25. --  if senderChannel==chanrec then
  26.       mon.write("on recoit le message suivant : "..message)
  27.       gotoln()
  28.       gotoln()
  29.       write("Appuyez sur ENTREE pour continuer ! ")
  30.       toto = read()
  31. --  end
  32.   modem.close(chanrec)
  33. end
Advertisement
Add Comment
Please, Sign In to add comment