Advertisement
Pdevo

tabellone

Feb 1st, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 KB | None | 0 0
  1. -- configurazione numero
  2.  
  3. n = 0
  4.  
  5. -- configurazione lato
  6.  
  7. l = " "
  8.  
  9. -- inizializzazione perifeiche
  10.  
  11. modem = nil
  12.  for _, side in pairs(rs.getSides()) do
  13.   if peripheral.getType(side) == "modem" then
  14.   modem = side
  15.   break
  16.   end
  17.  end
  18.  
  19. monitor = nil
  20.  for _, side in pairs(rs.getSides()) do
  21.   if peripheral.getType(side) == "monitor" then
  22.   monitor = side
  23.   break
  24.   end
  25.  end
  26.  
  27. -- codice avvio
  28.  
  29. sleep(1)
  30. print("< "..n.." >")
  31. sleep(1)
  32. print("tabellone")
  33. sleep(1)
  34. print("assegnazione")
  35. sleep(1)
  36. print("inizializzazione")
  37. sleep(1)
  38. print("connessione")
  39. rednet.open(modem)
  40. rednet.broadcast("avvio_tabellone_"..n)
  41. sleep(1)
  42. print("funzionamento")
  43.  
  44. -- codice sistema  
  45.    
  46. while true do
  47. local senderID, message = rednet.receive()
  48. local words = {}
  49.  
  50. for word in string.gmatch(message, "%w+") do words[#words + 1] = word end
  51.  
  52.  if words[1] == "sistemi" then
  53.  
  54.   if words[2] == "tabellone" then
  55.  
  56.    if tonumber(words[3]) == n then
  57.    
  58.     if words[4] == "spegnimento" then
  59.    
  60.     rednet.broadcast("spegnimento_tabellone_"..n)
  61.     os.shutdown()
  62.     end
  63.    
  64.     if words[4] == "riavvio" then
  65.     rednet.broadcast("riavvio_tabellone_"..n)
  66.     os.reboot()
  67.     end
  68.    
  69.    end
  70.    
  71.   end
  72.  
  73.  else
  74.  
  75.  term.redirect(peripheral.wrap(monitor))
  76.  print(message)
  77.  end
  78.  
  79. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement