Advertisement
quenti77

LampeMoniteur

Jun 29th, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.46 KB | None | 0 0
  1. rednetSide = "back"
  2. startPC = 4
  3. starting = false
  4.  
  5. resultat = {0, 0, 0, 0}
  6. direction = {"bottom", "right", "top", "left"}
  7.  
  8. rednet.open(rednetSide)
  9.  
  10. function addLight(l, s)
  11.     resultat[s] = resultat[s] + l
  12. end
  13.  
  14. function removeLight(l, s)
  15.     resultat[s] = resultat[s] - l
  16. end
  17.  
  18. function clearLight(s)
  19.     resultat[s] = 0
  20. end
  21.  
  22. function clearAllLight()
  23.     for i = 1, 4 do
  24.         clearLight(i)
  25.     end
  26. end
  27.  
  28. function activeLight(s)
  29.     resultat[s] = 65535
  30. end
  31.  
  32. function activeAllLight()
  33.     for i = 1, 4 do
  34.         activeLight(i)
  35.     end
  36. end
  37.  
  38. function refresh()
  39.     for i = 1, 4 do
  40.         rs.setBundledOutput(direction[i], resultat[i])
  41.     end
  42. end
  43.  
  44. function defilement()
  45.     for i = 1, 4 do
  46.         mx = 15
  47.        
  48.         if i == 4 then
  49.             mx = 1
  50.         end
  51.        
  52.         for j = 0, mx do
  53.             nombre = 2^mx
  54.             addLight(nombre, i)
  55.             refresh()
  56.             sleep(0.3)
  57.             clearLight(i)
  58.         end
  59.     end
  60. end
  61.  
  62. function allMove(mt)
  63.     for i = 1, mt do
  64.         defilement()
  65.     end
  66. end
  67.  
  68. while starting == false do
  69.     local id, msg, d = rednet.receive()
  70.    
  71.     if id ~= nil and msg ~= nil then
  72.         if id == startPC and msg == "lancement" then
  73.             starting = true
  74.         end
  75.     end
  76.     sleep(0.1)
  77. end
  78.  
  79. while starting == true do
  80.     local id, msg, d = rednet.receive(0.1)
  81.    
  82.     if id ~= nil and msg ~= nil then
  83.         if id == startPC and msg == "arret" then
  84.             starting = false
  85.         end
  86.     end
  87.    
  88.     rndFunc = math.random(1, 3)
  89.    
  90.     if rndFunc == 1 then
  91.        
  92.     elseif rndFunc == 2 then
  93.     elseif rndFunc == 3 then
  94.     else
  95.     end
  96.    
  97.     sleep(0.1)
  98. end
  99.  
  100. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement