Advertisement
ALpha_R

rcServer

Dec 6th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.53 KB | None | 0 0
  1.  
  2. -- gestion ordi portable
  3. -- faire tbscreen.lua + rcscreen.lua
  4. --
  5. -- + qd tu clique ca provoque une erreur sur la reception de info.bt dans rcButton
  6. -------------------------------------------------//Initialisation
  7.  
  8. local ptc = "reactorNetwork"
  9. local hostname = "rcServer"
  10.  
  11. rednet.open("top")
  12. rednet.host(ptc, hostname)
  13.  
  14. local rcScreen, tbScreen, rcComputer, rcButton, res
  15.  
  16. local info = {}
  17. local button = {}
  18.  
  19. -------------------------------------------------//Connection aux clients
  20.  
  21. rcScreen = rednet.lookup(ptc, "rcScreen")
  22. tbScreen = rednet.lookup(ptc, "tbScreen")
  23. rcButton = rednet.lookup(ptc, "rcButton")
  24. rcComputer = rednet.lookup(ptc, "rcComputer")
  25.  
  26. -------------------------------------------------//getInfo()
  27.  
  28. function getInfo()
  29.     print("Getting info ...")
  30.     res, info = rednet.receive(ptc, 10)
  31. end
  32.  
  33. -------------------------------------------------//sendInfo()
  34.  
  35. function sendInfo()
  36.     print("Sending info ...")
  37.     rednet.send(rcScreen, info.rc, ptc)
  38.     rednet.send(tbScreen, info.tb, ptc)
  39.     rednet.send(rcButton, info.bt, ptc)
  40. end
  41.  
  42. -------------------------------------------------//getButton()
  43.  
  44. function getButton()
  45.     print("Getting event ...")
  46.     res, button = rednet.receive(ptc, 10)
  47. end
  48.  
  49. -------------------------------------------------//sendComputer()
  50.  
  51. function sendComputer()
  52.     print("Sending event ...")
  53.     rednet.send(rcComputer, button, ptc)
  54. end
  55.  
  56. -------------------------------------------------//Main Script
  57.  
  58. while(true)do
  59.     os.sleep(0)
  60.     getInfo()
  61.     sendInfo()
  62.     getButton()
  63.     sendComputer()
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement