Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --config
- rednet.open("left")
- local ecran=peripheral.wrap("top")
- local ecranR=peripheral.wrap("monitor_8")
- local nbm = 8 --1 a 8
- local data100={} --pour reactor
- local data={} --pour les turbins
- data[1]={}
- data[2]={}
- data[3]={}
- data[4]={}
- data[5]={}
- data[6]={}
- data[7]={}
- data[8]={}
- windows = {}
- windows[1] = window.create(m, 1 , 2 , 5, 5, true)
- windows[2] = window.create(m, 50, 2 , 5, 5, true)
- windows[3] = window.create(m, 1 , 11, 5, 5, true)
- windows[4] = window.create(m, 50, 11, 5, 5, true)
- windows[5] = window.create(m, 1 , 21, 5, 5, true)
- windows[6] = window.create(m, 50, 21, 5, 5, true)
- windows[7] = window.create(m, 1 , 31, 5, 5, true)
- windows[2] = window.create(m, 50, 31, 5, 5, true)
- local turb
- local k=0
- -- function de recuperation des infos envoye en wifi
- function Ecoute()
- while true do
- local event, id, ID, TablData = os.pullEvent("rednet_message")
- if ID>=1 and ID<=8 then
- --print(ID)
- data[ID]=textutils.unserialize(TablData)
- elseif ID==100 then
- data100=textutils.unserialize(TablData)
- end
- end
- end
- function Affichage()
- --chargement
- ecran.setBackgroundColor(colors.blue)
- ecran.clear()
- line(30 ,20,10 ,1, colors.black)
- local cpt=1
- for cpt=1, 10 do
- line(30 ,20 ,cpt ,1, colors.green)
- os.sleep(0.3)
- end
- os.sleep(0.5)
- ecran.setBackgroundColor(colors.black)
- ecran.clear()
- AffichageTurbine()
- AffichageReactor()
- end
- -- function d'affichage les donners des turbines
- function AffichageTurbine()
- k=k+1
- if k == 5 then k = 1 end
- local i=1
- for i=1,nbm do --data[1] a data[8]
- --print(i)
- --chois de la position
- local x=1 y=1
- if i==1 then x=1 y=1
- elseif i==2 then x=1 y=50
- elseif i==3 then x=10 y=1
- elseif i==4 then x=10 y=50
- elseif i==5 then x=20 y=1
- elseif i==6 then x=20 y=50
- elseif i==7 then x=30 y=1
- elseif i==8 then x=30 y=50
- end
- --debut de l'affiche+5
- ecran.setTextColor(colors.white)
- ecran.setCursorPos(y,x) --**--
- ecran.write("Turbine "..i)
- --l'activiter
- if data[i]["gActive"]==true then
- turb = paintutils.loadImage("turb"..k)
- else
- turb = paintutils.loadImage("turb0")
- end
- windows[i].setBackgroundColor(colors.black)
- windows[i].setTextColor(colors.black)
- windows[i].clear()
- term.redirect(windows[i])
- paintutils.drawImage(turb, 1, 1)
- --l'engagement
- if data[i]["gInductor"]==true then
- line(y+10 ,x+1+5 ,7 ,1, colors.green)
- ecran.setCursorPos(y+10,x+1)
- ecran.write("Engager")
- ecran.setBackgroundColor(colors.black)
- ecran.write(" ")
- else
- line(y+10 ,x+1+5 ,10 ,1, colors.red)
- ecran.setCursorPos(y+10,x+1)
- ecran.write("Desengager")
- ecran.setBackgroundColor(colors.black)
- end
- --la vitesse du Rotor
- ecran.setTextColor(colors.white)
- ecran.setCursorPos(y,x+2+5) --**--
- ecran.write("Rotor : ")
- if data[i]["gSpeed"]<800 then
- ecran.setTextColor(colors.red)
- elseif data[i]["gSpeed"]<1000 then
- ecran.setTextColor(colors.blue)
- elseif data[i]["gSpeed"]<1700 then
- ecran.setTextColor(colors.red)
- elseif data[i]["gSpeed"]<1900 then
- ecran.setTextColor(colors.blue)
- else
- ecran.setTextColor(colors.red)
- end
- ecran.setCursorPos(y+8,x+2+5)
- ecran.write(number_format(data[i]["gSpeed"]).." RPM ")
- ecran.setTextColor(colors.white)
- ecran.setCursorPos(y,x+3+5) --**--
- ecran.write("Prod : "..number_format(data[i]["gProductLastTick"]).." RF/t ")
- ecran.setCursorPos(y,x+4+5) --**--
- ecran.write("Buffer : "..number_format(data[i]["gBuffer"]).." RF ")
- ecran.setCursorPos(y+20,x+4+5)
- ecran.write(math.ceil(data[i]["gBuffer"]/10000).."% ")
- os.sleep(0.5)
- end
- end
- end
- -- function d'affichage des donners du rector
- function AffichageReactor()
- local y=27 x=1
- while true do
- --affichage de l'activiter
- ecran.setCursorPos(y,x)
- ecran.write("Reactor")
- if data100["gActive"]==true then
- line(y ,x+1 ,6 ,1, colors.green)
- ecran.setCursorPos(y,x+1)
- ecran.write("Active")
- ecran.setBackgroundColor(colors.black)
- ecran.write(" ")
- else
- line(y+8 ,x+1 ,8 ,1, colors.red)
- ecran.setCursorPos(y,x+1)
- ecran.write("Desactive ")
- ecran.setBackgroundColor(colors.black)
- end
- --affichage des donnes
- ecran.setTextColor(colors.white)
- ecran.setCursorPos(y,x+2) --le stock de yell en ingot
- ecran.write("Fuel : "..number_format(data100["gFuelAmount"]/1000).." yell")
- ecran.setCursorPos(y,x+3) --le stock de yell en %
- ecran.write("Stock : "..math.ceil(data100["gFuelAmount"]/data100["gFuelAmountMax"]*100).."%")
- ecran.setCursorPos(y,x+4) --production en mb/t
- ecran.write("Prod : "..number_format(data100["gHotFluidProducedLastTick"]).." mb/t ")
- ecran.setCursorPos(y,x+5) --comsomation de yell en mb
- ecran.write("Conso : "..number_format(data100["gFuelConsumedLastTick"]))
- ecran.setCursorPos(y+16,x+5)
- ecran.write(" mb/t de yell")
- ecran.setCursorPos(y,x+6) --temperature en C
- ecran.write("temp : "..number_format(data100["gCasingtemperature"]).." C ")
- ecran.setCursorPos(y,x+7) --reactiviter %
- ecran.write("reacti : "..number_format(data100["gFuelReactivity"]).." % ")
- -- affichage de l'etat des rods
- for i=1,data["gNumberRods"] do
- ecran.setCursorPos(y,x+i+7)
- ecran.write("Rod "..i.." : ")
- ecran.setCursorPos(y+8,x+i+7)
- ecran.write(data100["gControlRodLevel"..i].."%")
- end
- os.sleep(0.5)
- end
- end
- function onoff()
- local type
- local a
- while true do
- local e, bt, xp, yp = os.pullEvent("monitor_touch")
- if bt=="top" then
- if (yp<8 and xp==2 ) then
- type ="turbin 1" a="actif"
- elseif xp>10 and xp<18 and yp==2 then
- type ="turbin 1" a="engag"
- elseif xp<8 and yp==9 then
- type ="turbin 2" a="actif"
- elseif xp>10 and xp<18 and yp==9 then
- type ="turbin 1" a="engag"
- --elseif xp<8 and yp==16 then
- -- type ="turbin 3"
- --elseif xp>27 and xp<35 and yp==2 then
- -- type ="turbin 4"
- --elseif xp>27 and xp<35 and yp==9 then
- -- type ="turbin 5"
- --elseif xp>27 and xp<35 and yp==16 then
- -- type ="turbin 6"
- end
- rednet.broadcast(type,a)
- os.sleep(0.5)
- end
- end
- end
- function onoffR()
- local type
- while true do
- local e, bt, xp, yp = os.pullEvent("monitor_touch")
- if bt=="monitor_8" then
- if yp==2 then
- type ="reactor"
- elseif yp==9 then
- type ="rod 1 +"
- elseif yp==10 then
- type ="rod 2 +"
- end
- rednet.broadcast(type)
- os.sleep(0.5)
- end
- end
- end
- --crestion de rectangle de couleur
- function line(x ,y ,long ,larg, color_font)
- ecran.setBackgroundColor(color_font)
- for yp=y, y+larg-1 do
- ecran.setCursorPos(x,yp)
- ecran.write(string.rep(" ", long))
- end
- end
- --bar de progresion
- function prog(x ,y ,long ,larg, valmin, valmax ,color_bar ,color_font)
- line(x ,y ,long ,larg, color_font)
- local bar = math.floor((valmin/valmax)*long)
- line(x ,y ,bar ,larg, color_bar)
- end
- -- function pour transformer 9876543 en 9 876 543
- function number_format(n)
- local test=mille(n)
- if test.Mille==0 then
- return math.floor(n)
- else
- test.Mille=mille(test.Mille)
- if test.Mille.Mille==0 then
- return test.Mille.Cent.." "..cent(test.Cent)
- else
- return test.Mille.Mille.." "..cent(test.Mille.Cent).." "..cent(test.Cent)
- end
- end
- end
- -- function pour etre sur d'avoir trois chiffre (99 devient 099, 9 devient 009)
- function cent(n)
- n=math.floor(n)
- if n>99 then
- return n
- elseif n>9 then
- return "0"..n
- else
- return "00"..n
- end
- end
- -- creer un objet avec les centaine d'un cotåA9 les millier de l'autre
- function mille(n)
- if n<1000 then
- return {Mille=0,Cent=n}
- else
- return {Mille=math.floor(n/1000),Cent=n%1000}
- end
- end
- parallel.waitForAll(Ecoute,Affichage)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement