Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------------
- BackgroundColor = colors.gray -- change la couleur du fond d'écran
- LigneColor = colors.white -- change la couleur des lignes
- ColorEnergy = colors.green
- ColorLave = colors.red
- MonitorSide = "top" -- attacher l'écran 3x6
- ConnecMax = 10 -- ne pas changer
- MaxEnergy = 1000000
- MaxTank = 10000
- Monitor = peripheral.wrap(MonitorSide)
- Machine = {}
- Energyy = {}
- Tankk = {}
- Tank = {}
- Energy = {}
- EnergyPourcent = {}
- TankPourcent = {}
- PourcentE = {}
- PourcentT = {}
- LeftRight = 1
- UpDown = 1
- PagePrecedente = 0
- PageActuelle = 1
- PageSuivante = 2
- PosY = 0
- rednet.open("left")
- idRednet = 3
- ------------------------------
- ------------------------------
- function Connexion()
- for ConnecMin=1,ConnecMax do
- Machine[ConnecMin] = peripheral.wrap("techreborn:thermal_generator_"..ConnecMin)
- end
- end
- ------------------------------
- ------------------------------
- function Affichage()
- Monitor.setBackgroundColor(BackgroundColor)
- Monitor.clear()
- Monitor.setCursorPos(31,2)
- Monitor.setTextColor(colors.red)
- Monitor.write("Interface !")
- Monitor.setTextColor(LigneColor)
- Monitor.setCursorPos(1,1) -- gauche = droite ou gauche , droite = hauteur
- Monitor.write("-----------------------------------------------------------------------")
- Monitor.setCursorPos(1,18)
- Monitor.write("-----------------------------------------------------------------------")
- Monitor.setCursorPos(1,19)
- Monitor.write("|")
- Monitor.setCursorPos(3,19)
- Monitor.setTextColor(colors.red)
- Monitor.write(PagePrecedente.."")
- Monitor.setTextColor(LigneColor)
- Monitor.setCursorPos(5,19)
- Monitor.write("|")
- Monitor.setCursorPos(31,19)
- Monitor.write("|")
- Monitor.setCursorPos(33,19)
- Monitor.setTextColor(colors.red)
- Monitor.write("Page: "..PageActuelle.."")
- Monitor.setTextColor(LigneColor)
- Monitor.setCursorPos(41,19)
- Monitor.write("|")
- Monitor.setCursorPos(67,19)
- Monitor.write("|")
- Monitor.setCursorPos(69,19)
- Monitor.setTextColor(colors.red)
- Monitor.write(PageSuivante.."")
- Monitor.setTextColor(LigneColor)
- Monitor.setCursorPos(71,19)
- Monitor.write("|")
- end
- ------------------------------
- ------------------------------
- function cadre()
- LeftRight = 2
- for n=1,4 do
- UpDown = UpDown + 2
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("-----------------")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("-----------------")
- LeftRight = LeftRight + 8
- UpDown = 3
- Monitor.setTextColor(colors.blue)
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- LeftRight = LeftRight + 8
- UpDown = 4
- Monitor.setTextColor(LigneColor)
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = UpDown + 1
- Monitor.setCursorPos(LeftRight,UpDown)
- Monitor.write("|")
- UpDown = 1
- LeftRight = LeftRight + 1
- end
- LeftRight = 3
- UpDown = 1
- end
- ------------------------------
- ------------------------------
- function donnee()
- for ConnecMin=1,ConnecMax do
- --if Energyy[ConnecMin] == nil then
- --else
- Energyy[ConnecMin] = Machine[ConnecMin].getDemandedEnergy()
- Tankk[ConnecMin] = Machine[ConnecMin].getTanks()
- Energy[ConnecMin] = MaxEnergy - Energyy[ConnecMin]
- EnergyPourcent[ConnecMin] = math.floor(Energy[ConnecMin]/MaxEnergy*100)
- PourcentE[ConnecMin] = math.floor(EnergyPourcent[ConnecMin]/10)
- --end
- --if Tankk[ConnecMin] == nil then
- --else
- if Tankk[ConnecMin][1]["amount"] == nil then
- Tank[ConnecMin] = 0
- TankPourcent[ConnecMin] = 0
- else
- Tank[ConnecMin] = Tankk[ConnecMin][1]["amount"]
- TankPourcent[ConnecMin] = math.floor(Tank[ConnecMin]/MaxTank*100)
- PourcentT[ConnecMin] = math.floor(TankPourcent[ConnecMin]/10)
- end
- --end
- end
- end
- ------------------------------
- ------------------------------
- function PrintDonne()
- for ConnecMin=1,ConnecMax do
- print(Energy[ConnecMin].."/"..MaxEnergy.." "..EnergyPourcent[ConnecMin].."%")
- print(Tank[ConnecMin].."/"..MaxTank.." "..TankPourcent[ConnecMin].."%")
- end
- end
- ------------------------------
- ------------------------------
- function red()
- id, message = rednet.receive((1)) -- TimeOut
- if id == idRednet and message == 0 then
- if PageActuelle == 1 then
- else
- print("0")
- PagePrecedente = PagePrecedente - 1
- PageActuelle = PageActuelle - 1
- PageSuivante = PageSuivante - 1
- Affichage()
- cadre()
- end
- end
- if id == idRednet and message == 1 then
- if PageActuelle == math.floor(ConnecMax/4+.5) then
- else
- print("1")
- PagePrecedente = PagePrecedente + 1
- PageActuelle = PageActuelle + 1
- PageSuivante = PageSuivante + 1
- Affichage()
- cadre()
- end
- end
- end
- ------------------------------
- ------------------------------
- function Writedonne()
- Affichage()
- cadre()
- function NP()
- if PageActuelle == 1 then
- return 1
- elseif PageActuelle == 2 then
- return 5
- elseif PageActuelle == 3 then
- return 9
- elseif PageActuelle == 4 then
- return 13
- elseif PageActuelle == 5 then
- return 17
- elseif PageActuelle == 6 then
- return 21
- elseif PageActuelle == 7 then
- return 25
- elseif PageActuelle == 8 then
- return 29
- elseif PageActuelle == 9 then
- return 33
- elseif PageActuelle == 10 then
- return 37
- elseif PageActuelle == 11 then
- return 41
- elseif PageActuelle == 12 then
- return 45
- elseif PageActuelle == 13 then
- return 49
- elseif PageActuelle == 14 then
- return 53
- elseif PageActuelle == 15 then
- return 57
- elseif PageActuelle == 16 then
- return 61
- elseif PageActuelle == 17 then
- return 65
- elseif PageActuelle == 18 then
- return 69
- elseif PageActuelle == 19 then
- return 73
- elseif PageActuelle == 20 then
- return 77
- end
- end
- local UpDownD = 16
- local LeftRightD = 1
- ConnecMin = NP()
- number = 1
- for i=0,3 do
- PosY = 14
- if Energy[ConnecMin] == nil then
- else
- Monitor.setCursorPos(LeftRightD,UpDownD)
- Monitor.setTextColor(ColorEnergy)
- Monitor.write(Energy[ConnecMin].."/1M".." "..EnergyPourcent[ConnecMin].."%")
- local UpDownD = UpDownD + 1
- Monitor.setCursorPos(LeftRightD,UpDownD)
- Monitor.setTextColor(ColorLave)
- Monitor.write(Tank[ConnecMin].."/"..MaxTank.." "..TankPourcent[ConnecMin].."%")
- LeftRightD = LeftRightD + 18
- if TankPourcent[ConnecMin] == 0 then
- else
- if number == 1 then
- PosZ = 3
- elseif number == 2 then
- PosZ = 20
- elseif number == 3 then
- PosZ = 37
- elseif number == 4 then
- PosZ = 54
- end
- PosY = 14
- for i=0,PourcentT[ConnecMin] do
- Monitor.setCursorPos(PosZ,PosY) --X = 3,11,20,28,37,45,54,62,
- Monitor.setBackgroundColor(colors.red)
- Monitor.write(" ")
- Monitor.setBackgroundColor(BackgroundColor)
- PosY = PosY - 1
- print("Pos de Lave: "..PosY.." Pos "..PosZ)
- end
- end
- if EnergyPourcent[ConnecMin] == 0 then
- else
- if number == 1 then
- PosZ = 11
- elseif number == 2 then
- PosZ = 28
- elseif number == 3 then
- PosZ = 45
- elseif number == 4 then
- PosZ = 62
- end
- PosY = 14
- for i=0,PourcentE[ConnecMin] do
- Monitor.setCursorPos(PosZ,PosY) --X = 3,11,20,28,37,45,54,62,
- Monitor.setBackgroundColor(colors.green)
- Monitor.write(" ")
- Monitor.setBackgroundColor(BackgroundColor)
- PosY = PosY - 1
- print("Pos de Energy: "..PosY.." Pos "..PosZ)
- end
- end
- ConnecMin = ConnecMin + 1
- print("-------------------------")
- print("Connec: "..ConnecMin)
- print("-------------------------")
- number = number + 1
- end
- end
- end
- ------------------------------
- ------------------------------
- Connexion()
- Affichage()
- cadre()
- donnee()
- while true do
- donnee()
- --PrintDonne()
- red()
- Writedonne()
- --sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement