Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- couleurs ---
- --- couleurs des cadres ---
- couleurCadreBase = colors.blue
- couleurCadrePassword = colors.lime
- --- couleurs des boutons password ---
- couleurButtonPassNum = colors.gray
- couleurButtonPassVal = colors.lime
- couleurButtonPassCor = colors.red
- --- couleurs des titres page principale ---
- couleurTitrePage = colors.lightGray
- couleurCarPage = colors.lightGray
- couleurCarVar = colors.gray
- --- initialisation fonctions ---
- --- fonction peripherals --
- mon = nil
- monSide = nil
- reader = nil
- readerSide = nil
- card = nil
- --- fonction page principale ---
- PagePrin = nil
- --- fonction barre nucleaire ---
- timeb = 10000
- --- fonction barre storage ---
- Stor1 = 0
- Stor2 = 0
- --- fonctions ---
- function peripherals()
- for i, side in pairs(rs.getSides()) do
- if peripheral.getType(side) == "monitor" then
- mon = peripheral.wrap(side)
- monSide = side
- end
- if peripheral.getType(side) == "nuclearReader" then
- reader = peripheral.wrap(side)
- readerSide = side
- end
- if reader ~= nil then
- uid,state,title,data= reader.get(1)
- if data == nil then
- sleep(1)
- peripherals()
- else
- for i,j in pairs(data) do
- if i == "liquidMeta" then card = 0 end
- if i == "heat" then card = 1 end
- if i == "energyL" then card = 2 end
- end
- end
- end
- end
- end
- function cadreBase()
- local cadreBase = {
- ' _______ _______ ',
- '| || |',
- '| ____||____ |',
- '| | | |',
- '| |__________| |',
- '| | | |',
- '| | | |',
- '| | | |',
- '| | | |',
- '| |____ ____| |',
- '| | || | |',
- '|__|____||____|__|'}
- for i = 1, #cadreBase do
- mon.setTextColor(couleurCadreBase)
- mon.setCursorPos(1,i)
- mon.write(cadreBase[i])
- end
- end
- function cadrePassword()
- local x = 0
- local cadrePassord = {
- '| || || || |',
- '|_||_||_||_|',
- '| || || || |',
- '|_||_||_||_|',
- ' | || | ',
- ' _|_||_|_',
- '| || |',
- '|___||___|'}
- for i = 1, #cadrePassword do
- if i<5 then x = 0 else x = 1 end
- mon.setTextColor(couleurPassword)
- mon.setCursorPos(4+x,i+3)
- mon.write(cadrePassword[i])
- end
- mon.setCursorPos(9,12)
- mon.setTextColor(couleurCadreBase)
- mon.write("__")
- end
- function buttonPassword()
- -- numButton, name, PosX, PosY, Couleur, Xmax
- buttonsPassword={
- {1 ,"1" ,5 ,4 ,couleurButtonPassNum ,5 },
- {2 ,"2" ,8 ,4 ,couleurButtonPassNum ,8 },
- {3 ,"3" ,11 ,4 ,couleurButtonPassNum ,11},
- {4 ,"4" ,14 ,4 ,couleurButtonPassNum ,14},
- {5 ,"5" ,5 ,6 ,couleurButtonPassNum ,5 },
- {6 ,"6" ,8 ,6 ,couleurButtonPassNum ,8 },
- {7 ,"7" ,11 ,6 ,couleurButtonPassNum ,11},
- {8 ,"8" ,14 ,6 ,couleurButtonPassNum ,14},
- {9 ,"9" ,8 ,8 ,couleurButtonPassNum ,8 },
- {10,"0" ,11 ,8 ,couleurButtonPassNum ,11},
- {11,"Val" ,6 ,10 ,couleurButtonPassVal ,8 },
- {12,"Cor" ,11 ,10 ,couleurButtonPassCor ,13}}
- for n,buttonP in ipairs(buttonsPassword) do
- mon.setCursorPos(buttonP[3],buttonP[4])
- mon.setTextColor(buttonP[5])
- -----------------------------------------------------------------------mettre le changement "Cor">"Ret" si le pin == nil
- mon.write(buttonP[2])
- end
- end
- function buttonPagePrin()
- datas()
- if card == 2 then
- datas()
- if tonumber(tostring(data["maxStorageL"])) == 10000000 then
- typestorage = " MFSu "
- storageOutput = " 512 "
- end
- if tonumber(tostring(data["maxStorageL"])) == 600000 then
- typestorage = " MFE "
- storageOutput = " 128 "
- end
- if tonumber(tostring(data["maxStorageL"])) == 40000 then
- typestorage = " Bat Box "
- storageOutput = " 32 "
- end
- else
- typestorage = " "
- storageOutput = " "
- end
- -- nameTank, nameReactor, nameStorage PosX, PosY, couleur
- buttonsPagePrin={
- {"Flux","Time","Flux",5,2,couleurTitrePage},
- {"Tank","Heat","Amps",11,2,couleurTitrePage},
- {title,title,title,5,4,couleurTitrePage},
- {" Type "," Max Heat "," Type ",5,6,couleurCarPage},
- {typetank," "..maxHeat,typestorage,5,7,couleurCarVar},
- {" Capacity "," Output "," Output ",5,8,couleurCarPage},
- {capaTank," "..output,storageOutput,5,9,couleurCarVar}
- }
- for n,buttonPage in ipairs(buttonsPagePrin) do
- mon.setCursorPos(buttonPage[4],buttonPage[5])
- mon.setTextColor(buttonPage[6])
- mon.write(buttonPage[1+card])
- end
- end
- function datas()
- uid, state, title, data = reader.get(1)
- if state== "OK" then
- if card == 0 then
- liquideMeta = tostring(data["liquidMeta"])
- capacity = tostring(data["capacity"])
- liquidId = tostring(data["liquidId"])
- amount = tostring(data["amount"])
- heat = 0
- isSteam = 0
- reactorPoweredB = 0
- maxHeat = 0
- timeLeft = 0
- output = 0
- maxAdmissibleHeat = 0
- energyL = 0
- maxStorageL = 0
- end
- if card == 1 then
- liquideMeta = 0
- capacity = 0
- liquidId = 0
- amount = 0
- heat = tostring(data["heat"])
- isSteam = tostring(data["isSteam"])
- reactorPoweredB = tostring(data["reactorPoweredB"])
- maxHeat = tostring(data["maxHeat"])
- timeLeft = tostring(data["timeLeft"])
- output = tostring(data["output"])
- maxAdmissibleHeat = (maxHeat/100*40)
- energyL = 0
- maxStorageL = 0
- end
- if card == 2 then
- liquideMeta = 0
- capacity = 0
- liquidId = 0
- amount = 0
- heat = 0
- isSteam = 0
- reactorPoweredB = 0
- maxHeat = 0
- timeLeft = 0
- output = 0
- maxAdmissibleHeat = 0
- energyL = tostring(data["energyL"])
- maxStorageL = tostring(data["maxStorageL"])
- end
- else
- peripherals()
- end
- end
- --- fonctions barres --
- function Barres()
- if card == 0 then print("tralala")
- end
- if card == 1 then
- barreTime()
- barreHeat()
- end
- if card == 2 then print("tralala")
- barreStorage()
- barreStorageFlux()
- end
- end
- function barreTime()
- if tonumber(timeLeft) > 0 then
- for i = 1,20 do
- if 100*timeLeft/timeb > math.abs(i-21)*5 then
- mon.setCursorPos(2,math.ceil(i/2)+1)
- mon.setTextColor(colors.lime)
- mon.setBackgroundColor(colors.lime)
- mon.write("##")
- else
- if 100*timeLeft/timeb < math.abs(i-21)*5 and 100*timeLeft/timeb > math.abs(i-20)*5 then
- mon.setCursorPos(2,math.ceil(i/2)+1)
- mon.setTextColor(colors.green)
- mon.setBackgroundColor(colors.green)
- mon.write("##")
- else
- mon.setCursorPos(2,math.ceil(i/2)+1)
- mon.setTextColor(colors.black)
- mon.setBackgroundColor(colors.black)
- mon.write(" ")
- end
- end
- end
- end
- mon.setBackgroundColor(colors.black)
- end
- function barreHeat()
- for i = 1,20 do
- if math.abs(i-21)*maxAdmissibleHeat/20 < tonumber(heat) and math.abs(i-22)*maxAdmissibleHeat/20 > tonumber(heat) then
- mon.setCursorPos(16,math.ceil(i/2)+1)
- mon.setTextColor(colors.orange)
- mon.setBackgroundColor(colors.orange)
- mon.write("##")
- else
- if math.abs(i-21)*maxAdmissibleHeat/20 < tonumber(heat) and math.abs(i-22)*maxAdmissibleHeat/20 < tonumber(heat) then
- mon.setCursorPos(16,math.ceil(i/2)+1)
- mon.setTextColor(colors.red)
- mon.setBackgroundColor(colors.red)
- mon.write("##")
- else
- mon.setCursorPos(16,math.ceil(i/2)+1)
- mon.setTextColor(colors.black)
- mon.setBackgroundColor(colors.black)
- mon.write(" ")
- end
- end
- end
- mon.setBackgroundColor(colors.black)
- end
- function barreStorage()
- for i = 1,20 do
- if energyL/maxStorageL*100 > math.abs(i-21)*5 and energyL/maxStorageL*100 < math.abs(i-22)*5 then
- mon.setCursorPos(16,math.ceil(i/2)+1)
- mon.setTextColor(colors.lightBlue)
- mon.setBackgroundColor(colors.lightBlue)
- mon.write("##")
- else
- if energyL/maxStorageL*100 >= math.abs(i-21)*5 and energyL/maxStorageL*100 >= math.abs(i-22)*5 then
- mon.setCursorPos(16,math.ceil(i/2)+1)
- mon.setTextColor(colors.cyan)
- mon.setBackgroundColor(colors.cyan)
- mon.write("##")
- else
- mon.setCursorPos(16,math.ceil(i/2)+1)
- mon.setTextColor(colors.black)
- mon.setBackgroundColor(colors.black)
- mon.write(" ")
- end
- end
- end
- mon.setBackgroundColor(colors.black)
- end
- function barreStorageFlux()
- if tonumber(maxStorageL) == 10000000 then storOutput = 512 end
- if tonumber(maxStorageL) == 600000 then storOutput = 128 end
- if tonumber(maxStorageL) == 40000 then storOutput = 32 end
- Stor2 = tonumber(energyL)
- PercStor = (Stor2-Stor1)/20
- PercStorOutput = ((PercStor/storOutput)*100)
- --- flux positif
- for i = 1,10 do
- if PercStorOutput > 0 and PercStorOutput > math.abs(i-11)*10 and PercStorOutput < math.abs(i-12)*10 then
- mon.setCursorPos(2,math.ceil(i/2)+1)
- mon.setTextColor(colors.lime)
- mon.setBackgroundColor(colors.lime)
- mon.write("##")
- else
- if PercStorOutput > 0 and PercStorOutput > math.abs(i-11)*10 and PercStorOutput > math.abs(i-12)*10 then
- mon.setCursorPos(2,math.ceil(i/2)+1)
- mon.setTextColor(colors.green)
- mon.setBackgroundColor(colors.green)
- mon.write("##")
- else
- mon.setCursorPos(2,math.ceil(i/2)+1)
- mon.setTextColor(colors.black)
- mon.setBackgroundColor(colors.black)
- mon.write(" ")
- end
- end
- end
- --- flux negatif
- for i = 1,10 do
- if PercStorOutput < 0 and math.abs(PercStorOutput) > i*10 and math.abs(PercStorOutput) < (i+1)*10 then
- mon.setCursorPos(2,math.ceil(i/2)+6)
- mon.setTextColor(colors.orange)
- mon.setBackgroundColor(colors.orange)
- mon.write("##")
- else
- if PercStorOutput < 0 and math.abs(PercStorOutput) > i*10 and math.abs(PercStorOutput) > (i+1)*10 then
- mon.setCursorPos(2,math.ceil(i/2)+6)
- mon.setTextColor(colors.red)
- mon.setBackgroundColor(colors.red)
- mon.write("##")
- else
- mon.setCursorPos(2,math.ceil(i/2)+6)
- mon.setTextColor(colors.black)
- mon.setBackgroundColor(colors.black)
- mon.write(" ")
- end
- end
- end
- mon.setBackgroundColor(colors.black)
- Stor1 = Stor2
- end
- --- Programme ---
- peripherals()
- cadreBase()
- while true do
- peripherals()
- datas()
- buttonPagePrin()
- Barres()
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment