Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Initialisation des peripheriques
- --Connexion par cable. Adapter les noms
- --Programme pour un ecran 6x5
- --sleep(1)
- affichage = peripheral.wrap("bottom")
- batterie = peripheral.wrap("mekanism_machine_0")
- reacteur = peripheral.wrap("BigReactors-Reactor_7")
- turbine1 = peripheral.wrap("BigReactors-Turbine_0")
- turbine2 = peripheral.wrap("BigReactors-Turbine_1")
- turbine3 = peripheral.wrap("BigReactors-Turbine_6")
- turbine4 = peripheral.wrap("BigReactors-Turbine_7")
- --
- --message moniteur
- print("")
- print("Programme de gestion de reacteur et turbines")
- print("Made by Rito_kun")
- print("")
- print("Appuyer sur CTRL + T pendant 2 secondes pour arreter le programme")
- --
- while true do
- maxBatterie = batterie.getMaxEnergyStored()
- reserveBatterie = batterie.getEnergyStored()
- pourcentBatterie = math.floor((reserveBatterie/maxBatterie)*100)
- vitesseRpmTurbine1 = math.floor(turbine1.getRotorSpeed())
- turbine1ProdEnergie = turbine1.getEnergyProducedLastTick()
- vitesseRpmTurbine2 = math.floor(turbine2.getRotorSpeed())
- turbine2ProdEnergie = turbine2.getEnergyProducedLastTick()
- vitesseRpmTurbine3 = math.floor(turbine3.getRotorSpeed())
- turbine3ProdEnergie = turbine3.getEnergyProducedLastTick()
- vitesseRpmTurbine4 = math.floor(turbine4.getRotorSpeed())
- turbine4ProdEnergie = turbine4.getEnergyProducedLastTick()
- totalProdEnergie = math.floor((turbine1ProdEnergie+turbine2ProdEnergie+turbine3ProdEnergie+turbine4ProdEnergie)/1000)
- totalProdEnergieRF = turbine1ProdEnergie+turbine2ProdEnergie+turbine3ProdEnergie+turbine4ProdEnergie
- consBatterieRF = batterie.getLastOutput()*0.4
- --consommation = totalProdEnergieRF-consBatterieRF
- rentabiliteRF = totalProdEnergieRF-consBatterieRF
- rentabilite_kRF = math.floor(rentabiliteRF/1000)
- if pourcentBatterie <= 5 then
- affichage.setTextColor(colors.white)
- affichage.setTextScale(1)
- affichage.setCursorPos(10,1)
- affichage.write("Batterie :")
- affichage.setTextColor(colors.red)
- affichage.setTextScale(1)
- affichage.setCursorPos(21,1)
- affichage.write(pourcentBatterie.." %")
- affichage.setTextColor(colors.white)
- affichage.setTextScale(1)
- affichage.setCursorPos(25,1)
- affichage.write(" sur 204,8 gRF")
- affichage.setTextColor(colors.white)
- affichage.setTextScale(1)
- affichage.setCursorPos(10,2)
- affichage.write("Production totale : "..totalProdEnergie.." kRF/t")
- if rentabilite_kRF >= 0 then
- affichage.setTextColor(colors.lime)
- affichage.setTextScale(1)
- affichage.setCursorPos(13,3)
- affichage.write("RentabilitåA9 : "..rentabilite_kRF.." kRF/t")
- end
- if rentabilite_kRF < 0 then
- affichage.setTextColor(colors.red)
- affichage.setTextScale(1)
- affichage.setCursorPos(13,3)
- affichage.write("RentabilitåA9 : "..rentabilite_kRF.." kRF/t")
- end
- end
- if pourcentBatterie > 5 then
- affichage.setTextColor(colors.white)
- affichage.setTextScale(1)
- affichage.setCursorPos(10,1)
- affichage.write("Batterie :")
- affichage.setTextColor(colors.green)
- affichage.setTextScale(1)
- affichage.setCursorPos(21,1)
- affichage.write(pourcentBatterie.." %")
- affichage.setTextColor(colors.white)
- affichage.setTextScale(1)
- affichage.setCursorPos(25,1)
- affichage.write(" sur 204,8 gRF")
- affichage.setTextColor(colors.white)
- affichage.setTextScale(1)
- affichage.setCursorPos(10,2)
- affichage.write("Production totale : "..totalProdEnergie.." kRF/t")
- if rentabilite_kRF >= 0 then
- affichage.setTextColor(colors.lime)
- affichage.setTextScale(1)
- affichage.setCursorPos(13,3)
- affichage.write("RentabilitåA9 : "..rentabilite_kRF.." kRF/t")
- if rentabilite_kRF < 0 then
- affichage.setTextColor(colors.red)
- affichage.setTextScale(1)
- affichage.setCursorPos(13,3)
- affichage.write("RentabilitåA9 : "..rentabilite_kRF.." kRF/t")
- end
- end
- if pourcentBatterie >= 95 then
- affichage.setTextColor(colors.white)
- affichage.setTextScale(1)
- affichage.setCursorPos(10,1)
- affichage.write("Batterie :")
- affichage.setTextColor(colors.green)
- affichage.setTextScale(1)
- affichage.setCursorPos(21,1)
- affichage.write(pourcentBatterie.." %")
- affichage.setTextColor(colors.white)
- affichage.setTextScale(1)
- affichage.setCursorPos(25,1)
- affichage.write(" sur 204,8 gRF")
- affichage.setTextColor(colors.white)
- affichage.setTextScale(1)
- affichage.setCursorPos(10,2)
- affichage.write("Production totale : "..totalProdEnergie.." kRF/t")
- end
- if rentabilite_kRF >= 0 then
- affichage.setTextColor(colors.lime)
- affichage.setTextScale(1)
- affichage.setCursorPos(13,3)
- affichage.write("RentabilitåA9 : "..rentabilite_kRF.." kRF/t")
- end
- if rentabilite_kRF < 0 then
- affichage.setTextColor(colors.red)
- affichage.setTextScale(1)
- affichage.setCursorPos(13,3)
- affichage.write("RentabilitåA9 : "..rentabilite_kRF.." kRF/t")
- end
- end
- if pourcentBatterie <= 5 then
- reacteur.setActive(true)
- turbine1.setInductorEngaged(false)
- turbine2.setInductorEngaged(false)
- turbine3.setInductorEngaged(false)
- turbine4.setInductorEngaged(false)
- end
- if pourcentBatterie >= 95 then
- reacteur.setActive(false)
- turbine1.setInductorEngaged(false)
- turbine2.setInductorEngaged(false)
- turbine3.setInductorEngaged(false)
- turbine4.setInductorEngaged(false)
- sleep(1)
- end
- -- affichage Turbines
- affichage.setTextColor(colors.lightBlue)
- affichage.setTextScale(1)
- affichage.setCursorPos(5,6)
- affichage.write("Turbine n¥B01")
- affichage.setTextColor(colors.white)
- affichage.setTextScale(1)
- affichage.setCursorPos(5,7)
- affichage.write(turbine1ProdEnergie.." RF/t")
- affichage.setTextColor(colors.gray)
- affichage.setTextScale(1)
- affichage.setCursorPos(5,8)
- affichage.write(vitesseRpmTurbine1.." RPM")
- affichage.setTextColor(colors.lightBlue)
- affichage.setTextScale(1)
- affichage.setCursorPos(5,10)
- affichage.write("Turbine n¥B02")
- affichage.setTextColor(colors.white)
- affichage.setTextScale(1)
- affichage.setCursorPos(5,11)
- affichage.write(turbine2ProdEnergie.." RF/t")
- affichage.setTextColor(colors.gray)
- affichage.setTextScale(1)
- affichage.setCursorPos(5,12)
- affichage.write(vitesseRpmTurbine2.." RPM")
- affichage.setTextColor(colors.lightBlue)
- affichage.setTextScale(1)
- affichage.setCursorPos(27,6)
- affichage.write("Turbine n¥B03")
- affichage.setTextColor(colors.white)
- affichage.setTextScale(1)
- affichage.setCursorPos(27,7)
- affichage.write(turbine3ProdEnergie.." RF/t")
- affichage.setTextColor(colors.gray)
- affichage.setTextScale(1)
- affichage.setCursorPos(27,8)
- affichage.write(vitesseRpmTurbine3.." RPM")
- affichage.setTextColor(colors.lightBlue)
- affichage.setTextScale(1)
- affichage.setCursorPos(27,10)
- affichage.write("Turbine n¥B04")
- affichage.setTextColor(colors.white)
- affichage.setTextScale(1)
- affichage.setCursorPos(27,11)
- affichage.write(turbine4ProdEnergie.." RF/t")
- affichage.setTextColor(colors.gray)
- affichage.setTextScale(1)
- affichage.setCursorPos(27,12)
- affichage.write(vitesseRpmTurbine4.." RPM")
- -- Affichage reacteur actif ou non
- --reacteur_activite = reacteur.getActive()
- if reacteur.getActive() == true then
- affichage.setTextColor(colors.red)
- affichage.setTextScale(1)
- affichage.setCursorPos(17,4)
- affichage.write("Reacteur Actif")
- end
- if reacteur.getActive() == false then
- affichage.setTextColor(colors.green)
- affichage.setTextScale(1)
- affichage.setCursorPos(17,4)
- affichage.write("Reacteur Inactif")
- end
- if vitesseRpmTurbine1 >= 1780 then
- turbine1.setInductorEngaged(true)
- end
- if vitesseRpmTurbine1 < 1770 then
- turbine1.setInductorEngaged(false)
- end
- if vitesseRpmTurbine2 >= 1780 then
- turbine2.setInductorEngaged(true)
- end
- if vitesseRpmTurbine2 < 1770 then
- turbine2.setInductorEngaged(false)
- end
- if vitesseRpmTurbine3 >= 1780 then
- turbine3.setInductorEngaged(true)
- end
- if vitesseRpmTurbine3 < 1770 then
- turbine3.setInductorEngaged(false)
- end
- if vitesseRpmTurbine4 >= 1780 then
- turbine4.setInductorEngaged(true)
- end
- if vitesseRpmTurbine4 < 1770 then
- turbine4.setInductorEngaged(false)
- end
- sleep(1.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement