Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Reactor = peripheral.wrap( "back" )
- local mon = peripheral.wrap( "left" )
- mon.setTextScale( .5 )
- local Manu, Auto = 1, 0
- xOn1, yOn1, xOn2, yOn2 = 3, 8, 9, 10
- xOff1, yOff1, xOff2, yOff2 = 11, 8, 17, 10
- function newLine(nbr)
- xPos, yPos = mon.getCursorPos()
- mon.setCursorPos( 1,( yPos + nbr ) )
- end
- function round(val, decimal)
- if (decimal) then
- return math.floor( (val * 10^decimal) + 0.5) / (10^decimal)
- else
- return math.floor(val+0.5)
- end
- end
- function drawOn()
- local previousTerm = term.current()
- term.redirect( mon )
- term.setBackgroundColour( colors.black )
- local xOn1, yOn1, xOn2, yOn2 = 2, 8, 25, 10
- local xOff1, yOff1, xOff2, yOff2 = 27, 8, 52, 10
- local x1_txt = 12
- local x2_txt = 38
- paintutils.drawFilledBox( xOn1, yOn1, xOn2, yOn2, colors.lime )
- term.setCursorPos( x1_txt, 9 )
- term.write( "START" )
- paintutils.drawFilledBox( xOff1, yOff1, xOff2, yOff2, colors.red )
- term.setCursorPos( x2_txt, 9 )
- term.write( "STOP" )
- term.setBackgroundColour( colors.black )
- term.redirect( previousTerm )
- end
- function drawOff()
- local previousTerm = term.current()
- term.redirect( mon )
- term.setBackgroundColour( colors.black )
- local xOn1, yOn1, xOn2, yOn2 = 2, 8, 25, 10
- local xOff1, yOff1, xOff2, yOff2 = 27, 8, 52, 10
- local x1_txt = 12
- local x2_txt = 38
- paintutils.drawFilledBox( xOn1, yOn1, xOn2, yOn2, colors.red )
- term.setCursorPos( x1_txt, 9 )
- term.write( "START" )
- paintutils.drawFilledBox( xOff1, yOff1, xOff2, yOff2, colors.lime )
- term.setCursorPos( x2_txt, 9 )
- term.write( "STOP" )
- term.setBackgroundColour( colors.black )
- term.redirect( previousTerm )
- end
- function drawMenu()
- local previousTerm = term.current()
- term.redirect( mon )
- term.setBackgroundColour( colors.black )
- paintutils.drawFilledBox( 2, 2, 13, 4, colors.lime )
- term.setCursorPos( 3, 3 )
- term.write( "Reacteur 1" )
- paintutils.drawFilledBox( 15, 2, 26, 4, colors.red )
- term.setCursorPos( 16, 3 )
- term.write( "Reacteur 2" )
- paintutils.drawFilledBox( 28, 2, 39, 4, colors.red )
- term.setCursorPos( 29, 3 )
- term.write( "Reacteur 3" )
- paintutils.drawFilledBox( 41, 2, 52, 4, colors.red )
- term.setCursorPos( 42, 3 )
- term.write( "Reacteur 4" )
- paintutils.drawFilledBox( 1, 6, 54, 6, colors.gray )
- paintutils.drawFilledBox( 54, 1, 54, 38, colors.gray )
- paintutils.drawFilledBox( 56, 2, 99, 4, colors.blue )
- term.setCursorPos( 75, 3 )
- term.write( "Général" )
- paintutils.drawFilledBox( 56, 6, 76, 8, colors.cyan )
- term.setCursorPos( 64, 7 )
- term.write( "Auto" )
- paintutils.drawFilledBox( 79, 6, 99, 8, colors.cyan )
- term.setCursorPos( 87, 7 )
- term.write( "Manu" )
- term.setBackgroundColour( colors.black )
- term.redirect( previousTerm )
- end
- function drawRed()
- local X1 = {2, 15, 28, 41, 42}
- local X2 = {13, 26, 39, 42}
- local T = {3, 16, 29, 42}
- for i=1, 4, 1
- do
- local previousTerm = term.current()
- term.redirect( mon )
- term.setBackgroundColour( colors.black )
- paintutils.drawFilledBox( X1[i], 2, X2[i], 4, colors.red )
- term.setCursorPos( T[i], 3 )
- term.write( "Reacteur "..i )
- term.setBackgroundColour( colors.black )
- term.redirect( previousTerm )
- end
- end
- function drawColor(x1, x2, y1, y2, txt_x, txt_y, txt, couleur)
- local previousTerm = term.current()
- term.redirect( mon )
- term.setBackgroundColour( colors.black )
- paintutils.drawFilledBox( x1, y1, x2, y2, couleur )
- term.setCursorPos( txt_x, txt_y )
- term.write( txt )
- term.setBackgroundColour( colors.black )
- term.redirect( previousTerm )
- end
- function drawActiveReac(idReac, txt)
- drawRed()
- if idReac == Reactor1 then
- local x1, x2, y1, y2, txt_x, txt_y, txt, couleur = 2, 13, 2, 4, 3, 3, "Reacteur 1", colors.lime
- drawColor(x1, x2, y1, y2, txt_x, txt_y, txt, couleur)
- elseif idReac == Reactor2 then
- local x1, x2, y1, y2, txt_x, txt_y, txt, couleur = 15, 26,2, 4, 16, 3, "Reacteur 2", colors.lime
- drawColor(x1, x2, y1, y2, txt_x, txt_y, txt, couleur)
- elseif idReac == Reactor3 then
- local x1, x2, y1, y2, txt_x, txt_y, txt, couleur = 28, 39, 2, 4, 29, 3, "Reacteur 3", colors.lime
- drawColor(x1, x2, y1, y2, txt_x, txt_y, txt, couleur)
- elseif idReac == Reactor4 then
- local x1, x2, y1, y2, txt_x, txt_y, txt, couleur = 41, 52, 2, 4, 42, 3, "Reacteur 4", colors.lime
- drawColor(x1, x2, y1, y2, txt_x, txt_y, txt, couleur)
- end
- end
- function drawMode()
- if Auto == 1 and Manu == 0 then
- local x1, x2, y1, y2, txt_x, txt_y, txt, couleur = 56, 76, 6, 8, 64, 7, "Auto", colors.lightBlue
- drawColor(x1, x2, y1, y2, txt_x, txt_y, txt, couleur)
- local x1, x2, y1, y2, txt_x, txt_y, txt, couleur = 79, 99, 6, 8, 87, 7, "Manu", colors.cyan
- drawColor(x1, x2, y1, y2, txt_x, txt_y, txt, couleur)
- elseif Auto == 0 and Manu == 1 then
- local x1, x2, y1, y2, txt_x, txt_y, txt, couleur = 56, 76, 6, 8, 64, 7, "Auto", colors.cyan
- drawColor(x1, x2, y1, y2, txt_x, txt_y, txt, couleur)
- local x1, x2, y1, y2, txt_x, txt_y, txt, couleur = 79, 99, 6, 8, 87, 7, "Manu", colors.lightBlue
- drawColor(x1, x2, y1, y2, txt_x, txt_y, txt, couleur)
- end
- end
- function infosGenerales()
- local prod1 = Reactor1.battery().producedLastTick()
- local prod2 = Reactor2.battery().producedLastTick()
- local total = prod1 + prod2
- local battery1 = Reactor1.battery().stored()
- local capa1 = Reactor1.battery().capacity()
- local battery2 = Reactor2.battery().stored()
- local capa2 = Reactor2.battery().capacity()
- local chargeBatt = round( ( (battery1 + battery2) / (capa1 + capa2) )* 100, 2)
- local conso = round( Reactor1.fuelTank().burnedLastTick() + Reactor2.fuelTank().burnedLastTick(), 2)
- mon.setCursorPos( 56, 10 )
- mon.write ( "Production Réacteur n°1 : " .. prod1 .. " RF/t " )
- mon.setCursorPos( 56, 12 )
- mon.write ( "Production Réacteur n°2 : " .. prod2 .. " RF/t " )
- mon.setCursorPos( 56, 14 )
- mon.write ( "Production totale : " .. total .. " RF/t " )
- mon.setCursorPos( 56, 16 )
- mon.write ( "Batterie totale : " .. chargeBatt .. " % " )
- mon.setCursorPos( 56, 18 )
- mon.write ("Consommation totale : " .. conso .. " mb/t ")
- end
- function Infos_Reac(idReac)
- viewedReac = idReac
- if viewedReac.active() then
- status = "On"
- drawOn()
- else
- status = "Off"
- drawOff()
- end
- local prod = viewedReac.battery().producedLastTick()
- local temp = round(viewedReac.fuelTemperature(), 2)
- local battery = viewedReac.battery().stored()
- local capa = viewedReac.battery().capacity()
- local chargeBatt = round(battery / capa * 100, 2)
- local conso = round(viewedReac.fuelTank().burnedLastTick(), 2)
- mon.setCursorPos( 1, 12 )
- mon.write ("Production : " .. prod .. " RF/t ")
- newLine(2)
- mon.write ("Température : " .. temp .. " °K ")
- newLine(2)
- mon.write ("Batterie : " .. battery .. " RF ( "..chargeBatt.." % ) ")
- newLine(2)
- mon.write ("Consommation : " .. conso .. " mb/t ")
- end
- function infos()
- infosGenerales()
- Infos_Reac(viewedReac)
- sleep( 0.1 )
- end
- function modeAuto(idReac)
- local battery = idReac.battery().stored()
- local capa = idReac.battery().capacity()
- local chargeBatt = round(battery / capa * 100, 2)
- if Auto == 1 and Manu == 0 then
- if chargeBatt >= 99 then
- idReac.setActive(false)
- elseif chargeBatt <= 15 then
- idReac.setActive(true)
- end
- end
- end
- function testClic()
- local event, side, cx, cy = os.pullEvent()
- if event == "monitor_touch" then
- if cy >= 2 and cy <= 4 then
- if cx >= 2 and cx <= 13 then
- drawActiveReac(Reactor1)
- Infos_Reac(Reactor1)
- elseif cx >= 15 and cx <= 26 then
- drawActiveReac(Reactor2)
- Infos_Reac(Reactor2)
- end
- elseif cy >= 8 and cy <= 10 then
- if cx >= 2 and cx <= 25 then
- drawOn()
- viewedReac.setActive(true)
- elseif cx >= 27 and cx <= 52 then
- drawOff()
- viewedReac.setActive(false)
- end
- elseif cy >= 6 and cy <= 8 then
- if cx >= 56 and cx <= 76 then
- Manu = 0
- Auto = 1
- drawMode()
- elseif cx >= 79 and cx <= 99 then
- Manu = 1
- Auto = 0
- drawMode()
- end
- end
- end
- end
- mon.setTextColor(colors.white)
- mon.setBackgroundColor(colors.black)
- mon.clear()
- drawMenu()
- viewedReac = Reactor1
- while true do
- parallel.waitForAny( infos, testClic )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement