Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m = peripheral.wrap("back")
- m.setBackgroundColor(colors.black)
- m.clear()
- --id = 52 to 58
- rednet.open("top")
- data = {}
- data[52] = {}
- data[53] = {}
- data[54] = {}
- data[55] = {}
- data[56] = {}
- data[57] = {}
- data[58] = {}
- local k = 0
- local l = 0
- local indexY = 1
- windows = {}
- local x = 10
- for i=0,5 do
- if i> 2 then x = 59 end
- local p = i*13
- if i> 2 then p = (i-3)*13 end
- windows[i+52] = window.create(m, x, p+3+indexY, 5, 5, true)
- end
- windows[58] = window.create(m, 33, 11+indexY, 7, 18, true)
- function afficheTurbines()
- k = k+1
- if k == 5 then k = 1 end
- local x = 6
- for i=0,5 do
- if i> 2 then x = 55 end
- local p = i*13
- if i> 2 then p = (i-3)*13 end
- local pt_turbine
- 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
- windows[i+52].setBackgroundColor(colors.black)
- windows[i+52].setTextColor(colors.black)
- windows[i+52].clear()
- term.redirect(windows[i+52])
- paintutils.drawImage(pt_turbine, 1, 1)
- m.setBackgroundColor(colors.black)
- m.setTextColor(colors.white)
- m.setCursorPos(x+2,p+1+indexY)
- m.write("Turbine "..(i+1))
- m.setCursorPos(x,p+9+indexY)
- m.write(data[i+52]["rotor"].." RPM ")
- m.setCursorPos(x,p+10+indexY)
- m.write(data[i+52]["energy"].." RF/t ")
- end
- end
- function affichereacteur()
- local pt_reacteur
- l= l+1
- if l == 4 then l = 1 end
- 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
- windows[58].setBackgroundColor(colors.black)
- windows[58].setTextColor(colors.black)
- windows[58].clear()
- term.redirect(windows[58])
- paintutils.drawImage(pt_reacteur, 1, 1)
- m.setBackgroundColor(colors.black)
- m.setTextColor(colors.white)
- m.setCursorPos(33,7+indexY)
- m.write("REACTOR")
- m.setCursorPos(31,31+indexY)
- m.write(data[58]["temp"].." C ")
- m.setCursorPos(31,33+indexY)
- m.write(string.sub(data[58]["fuel"], 1, 7).." mb/t ")
- end
- function fetchData()
- while true do
- e,a,b,c = os.pullEvent("rednet_message")
- if (a >= 52 and a <= 58) then
- data[a] = textutils.unserialize(b)
- end
- end
- end
- function afficheData()
- os.sleep(5) --wait pour les premiers retours
- while true do
- afficheTurbines()
- affichereacteur()
- --m.setCursorPos(1,1)
- --m.write("Réacteur ")
- --m.setCursorPos(5,2)
- --local actif = ""
- --if data[58]["active"] then actif = "oui" else actif = "non" end
- --m.write("actif ? : "..actif)
- --m.setCursorPos(5,3)
- --m.write("Temperature : "..data[58]["temp"].." C")
- --m.setCursorPos(5,4)
- --m.write("Conso : "..data[58]["fuel"].." mb/t")
- os.sleep(0.5)
- end
- end
- parallel.waitForAll(fetchData, afficheData)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement