Advertisement
Guest User

fix_ayturbine_errSymboleDeg

a guest
Feb 6th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
  32. function afficheTurbines()
  33. k = k+1
  34. if k == 5 then k = 1 end
  35.  
  36. local x = 6
  37.  
  38. for i=0,5 do
  39. if i> 2 then x = 55 end
  40.  
  41. local p = i*13
  42. if i> 2 then p = (i-3)*13 end
  43. local pt_turbine
  44.  
  45. if data[i+52]["active"] == 1 then pt_turbine = paintutils.loadImage("pt/pt_turbine_on_"..k) else pt_turbine = paintutils.loadImage("pt/pt_turbine_off") end
  46.  
  47. windows[i+52].setBackgroundColor(colors.black)
  48. windows[i+52].setTextColor(colors.black)
  49. windows[i+52].clear()
  50.  
  51.  
  52. term.redirect(windows[i+52])
  53. paintutils.drawImage(pt_turbine, 1, 1)
  54. m.setBackgroundColor(colors.black)
  55. m.setTextColor(colors.white)
  56.  
  57. m.setCursorPos(x+2,p+1+indexY)
  58. m.write("Turbine "..(i+1))
  59. m.setCursorPos(x,p+9+indexY)
  60. m.write(data[i+52]["rotor"].." RPM ")
  61. m.setCursorPos(x,p+10+indexY)
  62. m.write(data[i+52]["energy"].." RF/t ")
  63. end
  64.  
  65. end
  66.  
  67. function affichereacteur()
  68. local pt_reacteur
  69. l= l+1
  70. if l == 4 then l = 1 end
  71.  
  72. 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
  73. windows[58].setBackgroundColor(colors.black)
  74. windows[58].setTextColor(colors.black)
  75. windows[58].clear()
  76.  
  77. term.redirect(windows[58])
  78. paintutils.drawImage(pt_reacteur, 1, 1)
  79. m.setBackgroundColor(colors.black)
  80. m.setTextColor(colors.white)
  81.  
  82. m.setCursorPos(33,7+indexY)
  83. m.write("REACTOR")
  84.  
  85. m.setCursorPos(31,31+indexY)
  86. m.write(data[58]["temp"].." C ")
  87. m.setCursorPos(31,33+indexY)
  88. m.write(string.sub(data[58]["fuel"], 1, 7).." mb/t ")
  89.  
  90. end
  91.  
  92. function fetchData()
  93. while true do
  94. e,a,b,c = os.pullEvent("rednet_message")
  95. if (a >= 52 and a <= 58) then
  96. data[a] = textutils.unserialize(b)
  97. end
  98. end
  99. end
  100.  
  101.  
  102. function afficheData()
  103. os.sleep(5) --wait pour les premiers retours
  104. while true do
  105.  
  106. afficheTurbines()
  107. affichereacteur()
  108. --m.setCursorPos(1,1)
  109. --m.write("Réacteur ")
  110. --m.setCursorPos(5,2)
  111. --local actif = ""
  112. --if data[58]["active"] then actif = "oui" else actif = "non" end
  113. --m.write("actif ? : "..actif)
  114. --m.setCursorPos(5,3)
  115. --m.write("Temperature : "..data[58]["temp"].." C")
  116. --m.setCursorPos(5,4)
  117. --m.write("Conso : "..data[58]["fuel"].." mb/t")
  118.  
  119.  
  120. os.sleep(0.5)
  121. end
  122. end
  123.  
  124. parallel.waitForAll(fetchData, afficheData)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement