Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------
- -- Controlador de reactor v1.1
- -- Programado por Nedrek
- -- https://www.youtube.com/user/NedrekGames
- -- Configuracion del reactor:
- -- 2 Turbinas y 1 Reactor con 4 rods
- -- Enfriamiento activo
- -- 2 pantallas 4x3 y 1 pantalla 8x3
- -- Cambiar el numero de paletas en
- -- paletasT0 y paletasT1
- --------------------------------------------
- local turbina0Nombre = "BigReactors-Turbine_0"
- local turbina1Nombre = "BigReactors-Turbine_1"
- local reactorNombre = "BigReactors-Reactor_0"
- local monitorT1Nombre = "monitor_1"
- local monitorT2Nombre = "monitor_2"
- local monitorT3Nombre = "monitor_3"
- local paletasT0=56
- local paletasT1=56
- local perc={"< 110%","< 100%","< 90%","< 80%","< 70%","< 60%","< 50%","< 40%","< 30%","< 20%","< 10%","< 0%"}
- local EsperaBucle = 2
- local turbina0
- local turbina1
- local reactor0
- local moniT1
- local moniT2
- local moniT3
- turbina0 = peripheral.wrap(turbina0Nombre)
- turbina1 = peripheral.wrap(turbina1Nombre)
- reactor0 = peripheral.wrap(reactorNombre)
- moniT1 = peripheral.wrap(monitorT1Nombre)
- moniT2 = peripheral.wrap(monitorT2Nombre)
- moniT3 = peripheral.wrap(monitorT3Nombre)
- w, h = moniT1.getSize()
- local testEncendido = {turbina0.getActive(),reactor0.getActive(),turbina1.getActive()}
- moniT1.clear()
- moniT2.clear()
- moniT3.clear()
- moniT1.setBackgroundColor(colors.black)
- moniT2.setBackgroundColor(colors.black)
- moniT3.setBackgroundColor(colors.black)
- local valT0EA=turbina0.getEnergyStored()
- local valT0Vel=turbina0.getRotorSpeed()
- local valT0EP=turbina0.getEnergyProducedLastTick()
- local valT1EA=turbina1.getEnergyStored()
- local valT1Vel=turbina1.getRotorSpeed()
- local valT1EP=turbina1.getEnergyProducedLastTick()
- local TurbX
- local TurbY
- local TurbText
- local TurbColor
- local PercBarColT0="white"
- local PercBarColT1="white"
- local EfecPaletasT0My=(paletasT0*25)+24
- local EfecPaletasT0Mn=(paletasT0*25)-24
- local EfecPaletasT1My=(paletasT1*25)+24
- local EfecPaletasT1Mn=(paletasT1*25)-24
- local function clon(TurbY,TurbX,TurbText, TurbColor)
- local ColorT
- if TurbColor=="red" then ColorT=colors.red end
- if TurbColor=="blue" then ColorT=colors.blue end
- if TurbColor=="orange" then ColorT=colors.orange end
- if TurbColor=="white" then ColorT=colors.white end
- if TurbColor=="black" then ColorT=colors.black end
- if TurbColor=="green" then ColorT=colors.green end
- moniT1.setTextColor(ColorT)
- moniT1.setCursorPos(TurbY, TurbX)
- moniT1.write(TurbText)
- moniT2.setTextColor(ColorT)
- moniT2.setCursorPos(TurbY, TurbX)
- moniT2.write(TurbText)
- end
- local function clon2V(TurbY,TurbX,Turb0Text,Turb1Text, TurbColor)
- local ColorT
- if TurbColor=="red" then ColorT=colors.red end
- if TurbColor=="blue" then ColorT=colors.blue end
- if TurbColor=="orange" then ColorT=colors.orange end
- if TurbColor=="white" then ColorT=colors.white end
- if TurbColor=="black" then ColorT=colors.black end
- if TurbColor=="green" then ColorT=colors.green end
- if TurbColor=="yellow" then ColorT=colors.yellow end
- moniT1.setTextColor(ColorT)
- moniT1.setCursorPos(TurbY, TurbX)
- moniT1.write(Turb0Text)
- moniT2.setTextColor(ColorT)
- moniT2.setCursorPos(TurbY, TurbX)
- moniT2.write(Turb1Text)
- end
- local function TextPanta(SetX, SetY, SetText, SetColor, SetPanta, UseLenTBox, LenTBox)
- local ColorT
- if UseLenTBox==true then SetX=SetX-1 end
- if SetColor=="red" then ColorT=colors.red end
- if SetColor=="blue" then ColorT=colors.blue end
- if SetColor=="orange" then ColorT=colors.orange end
- if SetColor=="white" then ColorT=colors.white end
- if SetColor=="black" then ColorT=colors.black end
- if SetColor=="green" then ColorT=colors.green end
- if SetColor=="yellow" then ColorT=colors.yellow end
- if SetPanta==1 then moniDef = peripheral.wrap(monitorT1Nombre) end
- if SetPanta==2 then moniDef = peripheral.wrap(monitorT2Nombre) end
- if SetPanta==3 then moniDef = peripheral.wrap(monitorT3Nombre) end
- moniDef.setTextColor(ColorT)
- if UseLenTBox==false then
- moniDef.setCursorPos(SetX, SetY)
- else
- moniDef.setCursorPos(SetX-string.len(SetText), SetY)
- end
- moniDef.write(SetText)
- if UseLenTBox == true then
- if (LenTBox-string.len(SetText)) > 0 then
- term.redirect(moniDef)
- paintutils.drawLine(SetX-(LenTBox-1),SetY,((SetX-LenTBox)+(LenTBox-string.len(SetText)))-1,SetY,colors.black)
- moniDef.setBackgroundColor(colors.black)
- end
- end
- end
- local function DibuBar(SetX1,SetY1,SetX2,SetY2,SetColor, SetPanta)
- local ColorT
- if SetColor=="red" then ColorT=colors.red end
- if SetColor=="blue" then ColorT=colors.blue end
- if SetColor=="orange" then ColorT=colors.orange end
- if SetColor=="white" then ColorT=colors.white end
- if SetColor=="black" then ColorT=colors.black end
- if SetColor=="green" then ColorT=colors.green end
- if SetColor=="yellow" then ColorT=colors.yellow end
- if SetPanta==1 then moniDef = peripheral.wrap(monitorT1Nombre) end
- if SetPanta==2 then moniDef = peripheral.wrap(monitorT2Nombre) end
- if SetPanta==3 then moniDef = peripheral.wrap(monitorT3Nombre) end
- term.redirect(moniDef)
- paintutils.drawLine(SetX1,SetY1,SetX2,SetY2,ColorT)
- moniDef.setBackgroundColor(colors.black)
- end
- local function DibujarPantalla()
- moniT1.clear()
- moniT2.clear()
- moniT3.clear()
- moniT1.setBackgroundColor(colors.black)
- moniT2.setBackgroundColor(colors.black)
- moniT3.setBackgroundColor(colors.black)
- clon(14, 1, "--", "white")
- clon(33, 1, "Nedrek", "orange")
- clon(34, 2, "V1.1", "orange")
- TextPanta(14,1,"--","white",3,false)
- TextPanta(76,1,"Nedrek","orange",3,false)
- TextPanta(77,2,"V1.1","orange",3,false)
- DibuBar(1,3,39,3,"white",1)
- DibuBar(1,3,39,3,"white",2)
- DibuBar(1,3,82,3,"white",3)
- clon2V(4,1,"TURBINA 0", "TURBINA 1", "orange")
- clon2V(3,2,turbina0Nombre, turbina1Nombre, "orange")
- TextPanta(6,1,"REACTOR", "orange", 3,false)
- TextPanta(3,2,reactorNombre, "orange", 3,false)
- DibuBar(33,19,33,8,"white",3)
- DibuBar(73,19,73,8,"white",3)
- DibuBar(63,19,63,8,"white",3)
- DibuBar(53,19,53,8,"white",3)
- DibuBar(43,19,43,6,"white",3)
- DibuBar(43,6,82,6,"white",3)
- DibuBar(34,8,82,8,"white",3)
- TextPanta(48,6," Control de nivel de los Rods ", "orange", 3,false)
- TextPanta(36,8," Fuel", "orange", 3,false)
- if (testEncendido[1] == true) then
- TextPanta(17,1,"ONLINE ", "green", 1,false)
- else
- TextPanta(17,1,"OFFLINE ", "red", 1, false)
- end
- if (testEncendido[3] == true) then
- TextPanta(17,1,"ONLINE ", "green", 2,false)
- else
- TextPanta(17,1,"OFFLINE ", "red", 2, false)
- end
- if (testEncendido[2] == true) then
- TextPanta(17,1,"ONLINE ", "green", 3, false)
- else
- TextPanta(17,1,"OFFLINE ", "red", 3, false)
- end
- clon(1, 4, "Energia Almacenada: ", "white")
- clon(1, 5, "Velocidad: ", "white")
- clon(1, 6, "Energia Producida: ", "white")
- clon(11, 8, "Vapor en tanque: ", "white")
- clon(11, 9, "Agua en tanque: ", "white")
- clon(11, 10, "Entrada: ", "white")
- clon(24, 15, "+ Entrada", "white")
- clon(12, 16, "1 10 99 1K", "white")
- clon(24, 17, "- Entrada", "white")
- clon(14, 19, "Encender/Apagar", "white")
- TextPanta(5,19, "Encender/Apagar", "white", 3, false)
- clon(35, 4, "RF", "red")
- clon(35, 5, "RPM", "red")
- clon(35, 6, "RF/T", "red")
- clon(35, 8, "mb", "red")
- clon(35, 9, "mb", "red")
- clon(35, 10, "mb/t", "red")
- TextPanta(1,6,"Temp Nucleo: ", "white", 3, false)
- TextPanta(1,8,"Temp Exterior: ", "white", 3, false)
- TextPanta(1,10,"Combustible: ", "white", 3, false)
- TextPanta(1,11,"Desechos: ", "white", 3, false)
- TextPanta(1,12,"Consumo : ", "white", 3, false)
- TextPanta(1,13,"Agua en tanque: ", "white", 3, false)
- TextPanta(1,14,"Vapor en tanque: ", "white", 3, false)
- TextPanta(1,15,"Eficiencia: ", "white", 3, false)
- TextPanta(1,16,"Uso del Nucleo: ", "white", 3, false)
- TextPanta(1,17,"Agotamiento Nucleo: ", "white", 3, false)
- TextPanta(29,6,"C", "red", 3, false)
- TextPanta(29,8,"C", "red", 3, false)
- TextPanta(29,10,"mb", "red", 3, false)
- TextPanta(29,11,"mb", "red", 3, false)
- TextPanta(29,12,"mb/t", "red", 3, false)
- TextPanta(29,13,"mb", "red", 3, false)
- TextPanta(29,14,"mb", "red", 3, false)
- TextPanta(29,15,"%", "red", 3, false)
- TextPanta(29,16,"%", "red", 3, false)
- TextPanta(29,17,"%", "red", 3, false)
- for i=2, 12 do
- local CP
- --if (i==1) then CP="red" else if (i==2) then CP="green" else CP="blue" end end
- --clon(4, i+7, perc[i], CP)
- TextPanta(37,i+7,perc[i], "green", 3, false)
- TextPanta(47,i+7,perc[i], "blue", 3, false)
- TextPanta(57,i+7,perc[i], "blue", 3, false)
- TextPanta(67,i+7,perc[i], "blue", 3, false)
- TextPanta(77,i+7,perc[i], "blue", 3, false)
- end
- for i=1, 12 do
- local CP
- if (i==1) then CP="red" else if (i==2) then CP="green" else CP="blue" end end
- clon(4, i+7, perc[i], CP)
- end
- for b=15,17,2 do
- for a=11,20,3 do
- DibuBar(a,b,a+1,b,"blue",1)
- end
- end
- DibuBar(11,19,12,19,"blue",1)
- for b=15,17,2 do
- for a=11,20,3 do
- DibuBar(a,b,a+1,b,"blue",2)
- end
- end
- DibuBar(11,19,12,19,"blue",2)
- DibuBar(2,19,3,19,"blue",3)
- DibuBar(((paletasT0*25)/74)+11,12,((paletasT0*25)/74)+11,12,"green",1)
- DibuBar(11,12,((paletasT0*25)/74)+10,12,"blue",1)
- DibuBar(((paletasT0*25)/74)+12,12,38,12,"red",1)
- DibuBar(((paletasT1*25)/74)+11,12,((paletasT1*25)/74)+11,12,"green",2)
- DibuBar(11,12,((paletasT1*25)/74)+10,12,"blue",2)
- DibuBar(((paletasT1*25)/74)+12,12,38,12,"red",2)
- end
- local function round(num)
- i, j = string.find(num, '.', 1, true)
- if i==nil then
- num=num..".00"
- else
- if i==string.len(num)-1 then
- num=num.."0"
- else
- num=string.sub(num,1,i+2)
- end
- end
- -- TextPanta(1,17,num, "blue", 3, false)
- return num
- end
- function DibPant ()
- while not finished do
- sleep(0)
- local valT0EA=turbina0.getEnergyStored()
- local valT0Vel=turbina0.getRotorSpeed()
- local valT0EP=turbina0.getEnergyProducedLastTick()
- local valT0VPT=turbina0.getInputAmount()
- local valT0VTS=turbina0.getOutputAmount()
- local valT0VSM=turbina0.getFluidFlowRate()
- local valT1EA=turbina1.getEnergyStored()
- local valT1Vel=turbina1.getRotorSpeed()
- local valT1EP=turbina1.getEnergyProducedLastTick()
- local valT1VPT=turbina1.getInputAmount()
- local valT1VTS=turbina1.getOutputAmount()
- local valT1VSM=turbina1.getFluidFlowRate()
- local valReactorCoreHeat=reactor0.getFuelTemperature()
- local valReactorCasingHeat=reactor0.getCasingTemperature()
- local valReactorFuelA=reactor0.getFuelAmount()
- local valReactorFuelW=reactor0.getWasteAmount()
- local valReactorFuelCLT=reactor0.getFuelConsumedLastTick()
- local valReactorCA=reactor0.getCoolantAmount()
- local valReactorHFA=reactor0.getHotFluidAmount()
- local valReactorFuelR=reactor0.getFuelReactivity()
- local valReactorFuelMax=reactor0.getFuelAmountMax()
- local valReactorCR0=reactor0.getControlRodName(0)
- local valReactorCR1=reactor0.getControlRodName(1)
- local valReactorCR2=reactor0.getControlRodName(2)
- local valReactorCR3=reactor0.getControlRodName(3)
- local valReactorCR0L=reactor0.getControlRodLevel(0)
- local valReactorCR1L=reactor0.getControlRodLevel(1)
- local valReactorCR2L=reactor0.getControlRodLevel(2)
- local valReactorCR3L=reactor0.getControlRodLevel(3)
- local dibBarraT1 = 19-(valT0Vel/185)
- local dibBarraT2 = 19-(valT1Vel/185)
- DibuBar(2,7,2,dibBarraT1-1,"black",1)
- DibuBar(2,19,2,dibBarraT1,"blue",1)
- DibuBar(2,7,2,dibBarraT2-1,"black",2)
- DibuBar(2,19,2,dibBarraT2,"blue",2)
- local PercVapT0=(valT0VSM/74)+10
- local PercVapT1=(valT1VSM/74)+10
- if valT0VSM<EfecPaletasT0My then PercBarColT0="blue" end
- if valT0VSM>EfecPaletasT0My then PercBarColT0="red" end
- if valT0VSM>=EfecPaletasT0My and valT0VSM<=EfecPaletasT0My then PercBarColT0="green" end
- if valT1VSM<EfecPaletasT1My then PercBarColT1="blue" end
- if valT1VSM>EfecPaletasT1My then PercBarColT1="red" end
- if valT1VSM>=EfecPaletasT1My and valT0VSM<=EfecPaletasT1My then PercBarColT1="green" end
- if PercVapT0<=11 then PercVapT0=11 end
- if PercVapT0>=38 then PercVapT0=38 end
- if PercVapT1<=11 then PercVapT1=11 end
- if PercVapT1>=38 then PercVapT1=38 end
- DibuBar(11,13,PercVapT0,13,PercBarColT0,1)
- DibuBar(39,13,PercVapT0+1,13,"black",1)
- DibuBar(11,13,PercVapT1,13,PercBarColT1,2)
- DibuBar(39,13,PercVapT1+1,13,"black",2)
- TextPanta(35, 4,round(valT0EA), "green", 1, true, 9)
- TextPanta(35, 4,round(valT1EA), "green", 2, true, 9)
- TextPanta(35, 5,round(valT0Vel), "green", 1, true, 9)
- TextPanta(35, 5,round(valT1Vel), "green", 2, true, 9)
- TextPanta(35, 6,round(valT0EP), "green", 1, true, 9)
- TextPanta(35, 6,round(valT1EP), "green", 2, true, 9)
- TextPanta(35, 8,round(valT0VPT), "green", 1, true, 6)
- TextPanta(35, 8,round(valT1VPT), "green", 2, true, 6)
- TextPanta(35, 9,round(valT0VTS), "green", 1, true, 9)
- TextPanta(35, 9,round(valT1VTS), "green", 2, true, 9)
- TextPanta(35, 10,round(valT0VSM), "green", 1, true, 9)
- TextPanta(35, 10,round(valT1VSM), "green", 2, true, 9)
- TextPanta(29, 6,round(valReactorCoreHeat), "green", 3, true, 12)
- TextPanta(29, 8,round(valReactorCasingHeat), "green", 3, true,12)
- TextPanta(29, 10,round(valReactorFuelA), "green", 3, true, 12)
- TextPanta(29, 11,round(valReactorFuelW), "green", 3, true, 12)
- TextPanta(29, 12,round(valReactorFuelCLT), "green", 3, true, 12)
- TextPanta(29, 13,round(valReactorCA), "green", 3, true, 12)
- TextPanta(29, 14,round(valReactorHFA), "green", 3, true, 12)
- TextPanta(29, 15,round(valReactorFuelR), "green", 3, true, 12)
- TextPanta(29, 16,round((100/valReactorFuelMax)*(valReactorFuelA+valReactorFuelW)), "green", 3, true, 12)
- TextPanta(29, 17,round((100/(valReactorFuelA+valReactorFuelW))*(valReactorFuelW)), "green", 3, true, 8)
- TextPanta(45, 8," "..valReactorCR0, "green", 3, false)
- TextPanta(55, 8," "..valReactorCR1, "green", 3, false)
- TextPanta(65, 8," "..valReactorCR2, "green", 3, false)
- TextPanta(75, 8," "..valReactorCR3, "green", 3, false)
- DibuBar(45,19,45,19-(valReactorCR0L/10),"blue",3)
- DibuBar(55,19,55,19-(valReactorCR1L/10),"blue",3)
- DibuBar(65,19,65,19-(valReactorCR2L/10),"blue",3)
- DibuBar(75,19,75,19-(valReactorCR3L/10),"blue",3)
- if valReactorCR0L ~= 100 then DibuBar(45,9,45,(19-(valReactorCR0L/10))-1,"black",3) end
- if valReactorCR1L ~= 100 then DibuBar(55,9,55,(19-(valReactorCR1L/10))-1,"black",3) end
- if valReactorCR2L ~= 100 then DibuBar(65,9,65,(19-(valReactorCR2L/10))-1,"black",3) end
- if valReactorCR3L ~= 100 then DibuBar(75,9,75,(19-(valReactorCR3L/10))-1,"black",3) end
- local PercHeatCore=((28/2000)*math.ceil(round(valReactorCoreHeat)))
- local PercHeatCasing=((28/2000)*math.ceil(round(valReactorCasingHeat)))
- if PercHeatCore<=30 then
- if PercHeatCore>=19 then
- DibuBar(2,7,20,7,"green",3)
- DibuBar(21,7,PercHeatCore+2,7,"red",3)
- else
- DibuBar(2,7,PercHeatCore+2,7,"green",3)
- end
- DibuBar(PercHeatCore+3,7,31,7,"black",3)
- end
- if PercHeatCasing<=30 then
- if PercHeatCasing>=19 then
- DibuBar(2,9,20,9,"green",3)
- DibuBar(21,9,PercHeatCasing+2,9,"red",3)
- else
- DibuBar(2,9,PercHeatCasing+2,9,"green",3)
- end
- DibuBar(PercHeatCasing+3,9,31,9,"black",3)
- end
- local Desechos= math.ceil(round((100/valReactorFuelMax)*valReactorFuelW)/10)
- local Combus= math.ceil(round((100/valReactorFuelMax)*valReactorFuelA)/10)
- if Desechos~=0 then DibuBar(35,19,35,(19-Desechos)+1,"blue",3) end
- if Combus~=0 then DibuBar(35,(19-Desechos),35,(19-Desechos)-Combus+1,"green",3) end
- local PecVeloT0=math.ceil((100/1800)*valT0Vel)
- local PecVeloT1=math.ceil((100/1800)*valT1Vel)
- TextPanta(18, 5,PecVeloT0.."%", "green", 1, true, 6)
- TextPanta(18, 5,PecVeloT1.."%", "green", 2, true, 6)
- end
- end
- function MoniTouch ()
- while not finished do
- local onoff = "nook"
- local Flowplus = 0
- local RodF=0
- local SetRod=5
- event, Monitor, w, h = os.pullEvent("monitor_touch")
- if Monitor == monitorT3Nombre then
- if (w>=2 and w<=3) and h==19 then onoff="ok" end
- if w==45 then RodF=0 end
- if w==55 then RodF=1 end
- if w==65 then RodF=2 end
- if w==75 then RodF=3 end
- if RodF ~= 5 then
- SetRod=(19-h)*10
- --TextPanta(1,18 ,SetRod.." "..RodF, "blue", 3, false)
- if SetRod<=100 then reactor0.setControlRodLevel(RodF,SetRod) end
- end
- else
- if (w>=11 and w<=12) and h==19 then onoff="ok" end
- if (w>=11 and w<=12) and h==17 then Flowplus=1999 end
- if (w>=14 and w<=15) and h==17 then Flowplus=1990 end
- if (w>=17 and w<=18) and h==17 then Flowplus=1900 end
- if (w>=20 and w<=21) and h==17 then Flowplus=1000 end
- if (w>=11 and w<=12) and h==15 then Flowplus=2001 end
- if (w>=14 and w<=15) and h==15 then Flowplus=2010 end
- if (w>=17 and w<=18) and h==15 then Flowplus=2100 end
- if (w>=20 and w<=21) and h==15 then Flowplus=3000 end
- end
- if Flowplus>=1 then
- if (Monitor==monitorT1Nombre) then
- local Flow=(tonumber(turbina0.getFluidFlowRate())+Flowplus)-2000
- if Flow>=2000 then Flow=2000 end
- if Flow<=1 then Flow=1 end
- turbina0.setFluidFlowRateMax(Flow)
- end
- if (Monitor==monitorT2Nombre) then
- end
- end
- if onoff == "ok" then
- if (Monitor==monitorT1Nombre) then
- if (testEncendido[1]==true) then
- turbina0.setActive(false)
- testEncendido[1]=false
- TextPanta(17,1,"OFFLINE ", "red", 1, false)
- else
- turbina0.setActive(true)
- testEncendido[1]=true
- TextPanta(17,1,"ONLINE ", "green", 1, false)
- end
- end
- if (Monitor==monitorT2Nombre) then
- if (testEncendido[3]==true) then
- turbina1.setActive(false)
- testEncendido[3]=false
- TextPanta(17,1,"OFFLINE ", "red", 2, false)
- else
- turbina1.setActive(true)
- testEncendido[3]=true
- TextPanta(17,1,"ONLINE ", "green", 2, false)
- end
- end
- if (Monitor==monitorT3Nombre) then
- if (testEncendido[2]==true) then
- reactor0.setActive(false)
- testEncendido[2]=false
- TextPanta(17,1,"OFFLINE ", "red", 3, false)
- else
- reactor0.setActive(true)
- testEncendido[2]=true
- TextPanta(17,1,"ONLINE ", "green", 3, false)
- end
- end
- end
- end
- end
- DibujarPantalla()
- while not finished do
- parallel.waitForAny(MoniTouch, DibPant)
- sleep(EsperaBucle)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement