Advertisement
midbird77

test

Dec 17th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.43 KB | None | 0 0
  1. m = peripheral.wrap("back")
  2. m.setBackgroundColor(colors.black)
  3. m.clear()
  4. --id = 52 to 58
  5.  
  6. rednet.open("top")
  7. data = {}
  8. data[52] = {}
  9. data[53] = {}
  10. data[54] = {}
  11. data[55] = {}
  12. data[56] = {}
  13. data[57] = {}
  14. data[58] = {}
  15.  
  16. local k = 0
  17. local l = 0
  18. local indexY = 1
  19.  
  20. windows = {}
  21.  
  22. local x = 10
  23. for i=0,5 do
  24.   if i> 2 then x = 59 end
  25.   local p = i*13
  26.   if i> 2 then p = (i-3)*13 end
  27.   windows[i+52] = window.create(m, x, p+3+indexY, 5, 5, true)
  28. end
  29. windows[58]  = window.create(m, 33, 11+indexY, 7, 18, true)
  30.  
  31. function affichereacteur()
  32.         local pt_reacteur
  33.         l= l+1
  34.         if l == 4 then l = 1 end
  35.                
  36.     if data[58]["active"] == 1 then pt_reacteur = paintutils.loadImage("pt/pt_reactor_on_"..l) else pt_turbine = paintutils.loadImage("pt/pt_reactor_off") end
  37.         windows[58].setBackgroundColor(colors.black)
  38.         windows[58].setTextColor(colors.black)
  39.         windows[58].clear()
  40.        
  41.         term.redirect(windows[58])
  42.         paintutils.drawImage(pt_reacteur, 1, 1)
  43.         m.setBackgroundColor(colors.black)
  44.         m.setTextColor(colors.white)
  45.        
  46.         m.setCursorPos(33,7+indexY)
  47.         m.write("REACTOR")
  48.        
  49.         m.setCursorPos(31,31+indexY)
  50.         m.write(data[58]["temp"].." °C           ")
  51.         m.setCursorPos(31,33+indexY)
  52.         m.write(string.sub(data[58]["fuel"], 1, 7).." mb/t          ")
  53.  
  54. end
  55.  
  56. function fetchData()
  57.         while true do  
  58.                 e,a,b,c = os.pullEvent("rednet_message")
  59.                 if (a >= 52 and a <= 58) then
  60.                         data[a] = textutils.unserialize(b)
  61.                 end
  62.         end
  63. end
  64.  
  65.  
  66. function afficheData()
  67.         os.sleep(5) --wait pour les premiers retours
  68.         while true do
  69.                
  70.                 afficheTurbines()
  71.                 affichereacteur()
  72.                 --m.setCursorPos(1,1)
  73.                 --m.write("Réacteur ")
  74.                 --m.setCursorPos(5,2)
  75.                 --local actif = ""
  76.                 --if data[58]["active"] then actif = "oui" else actif = "non" end
  77.                 --m.write("actif ?     : "..actif)
  78.                 --m.setCursorPos(5,3)
  79.                 --m.write("Temperature : "..data[58]["temp"].." °C")
  80.                 --m.setCursorPos(5,4)
  81.                 --m.write("Conso       : "..data[58]["fuel"].." mb/t")
  82.                
  83.  
  84.         os.sleep(0.5)
  85.         end
  86. end
  87.  
  88. parallel.waitForAll(fetchData, afficheData)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement