Posted 30 November 2014 - 09:28 AM
I try to do a program which display the Reactor and turbines statistics on a screen.
I have 2 computer who emit on rednet the informations from the first turbine and the reactor.
This program won't work since i add the Reactor part.
This is the display program.
The computer for reactor get the id 2 and the computer for the turbine get the id 20
If you need the programs in the 2 other computer ask me pls.
And really sorry for my english.
I have 2 computer who emit on rednet the informations from the first turbine and the reactor.
This program won't work since i add the Reactor part.
This is the display program.
local screen = peripheral.wrap("left")
rednet.open("top")
data = {}
data[20] = {}
data[2] = {}
os.sleep(2)
--Windows
local t1 = window.create(screen,1,1,29,19)
local t2 = window.create(screen,53,1,29,19)
local r1 = window.create(screen,30,1,24,40)
function fetchData()
while true do
e,a,b,c = os.pullEvent("rednet_message")
if (a == 2 or a == 20) then
data[a] = textutils.unserialize(B)/>
end
end
end
function Tu1() --Turbine1 display
term.redirect(t1)
if data[20]["Etat"] == 1 then turbine_statut = paintutils.loadImage("image/turbine_on_1") else turbine_statut = paintutils.loadImage("image/turbine_off") end
t1.setBackgroundColor(colors.black)
t1.clear()
t1.setCursorPos(10, 1)
t1.write("Turbine 1")
t1.setCursorPos(3, 17)
t1.print("Rotor Speed : "..data[20]["Rotor"].." RPM")
t1.setCursorPos(3, 19)
t1.print("Energy Buffer : "..textutils.serialize(data[20]["Energy"]).." RF/t")
paintutils.drawImage(turbine_statut, 9, 4)
end
function Re1() --Reactor display
term.redirect(r1)
if data[2]["Active"] == 1 then reactor_statut = paintutils.loadImage("image/reactor_on_1") else reactor_statut = paintutils.loadImage("image/reactor_off") end
r1.setBackgroundColor(colors.black)
r1.clear()
r1.setCursorPos(10, 1)
r1.write("Reactor")
paintutils.drawImage(reactor_statut, 8, 5)
end
function afficheData()
os.sleep(5)
while true do
Re1()
Tu1()
end
end
parallel.waitForAll(fetchData, afficheData)
The computer for reactor get the id 2 and the computer for the turbine get the id 20
If you need the programs in the 2 other computer ask me pls.
And really sorry for my english.
Edited on 02 December 2014 - 06:38 AM