Advertisement
Nedrek

Controlador BigReactors V1.1

Jul 24th, 2014
470
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 18.18 KB | None | 0 0
  1. --------------------------------------------
  2. -- Controlador de reactor v1.1
  3. -- Programado por Nedrek
  4. -- https://www.youtube.com/user/NedrekGames
  5. -- Configuracion del reactor:
  6. -- 2 Turbinas y 1 Reactor con 4 rods
  7. -- Enfriamiento activo
  8. -- 2 pantallas 4x3 y 1 pantalla 8x3
  9. -- Cambiar el numero de paletas en
  10. -- paletasT0 y paletasT1
  11. --------------------------------------------
  12.  
  13. local turbina0Nombre = "BigReactors-Turbine_0"
  14. local turbina1Nombre = "BigReactors-Turbine_1"
  15. local reactorNombre = "BigReactors-Reactor_0"
  16. local monitorT1Nombre = "monitor_1"
  17. local monitorT2Nombre = "monitor_2"
  18. local monitorT3Nombre = "monitor_3"
  19. local paletasT0=56
  20. local paletasT1=56
  21.  
  22.  
  23. local perc={"< 110%","< 100%","<  90%","<  80%","<  70%","<  60%","<  50%","<  40%","<  30%","<  20%","<  10%","<   0%"}
  24. local EsperaBucle = 2  
  25. local turbina0
  26. local turbina1
  27. local reactor0
  28. local moniT1
  29. local moniT2
  30. local moniT3
  31.  
  32. turbina0 = peripheral.wrap(turbina0Nombre)
  33. turbina1 = peripheral.wrap(turbina1Nombre)
  34. reactor0 = peripheral.wrap(reactorNombre)
  35. moniT1 = peripheral.wrap(monitorT1Nombre)
  36. moniT2 = peripheral.wrap(monitorT2Nombre)
  37. moniT3 = peripheral.wrap(monitorT3Nombre)
  38. w, h = moniT1.getSize()
  39. local testEncendido = {turbina0.getActive(),reactor0.getActive(),turbina1.getActive()}
  40. moniT1.clear()
  41. moniT2.clear()
  42. moniT3.clear()
  43. moniT1.setBackgroundColor(colors.black)
  44. moniT2.setBackgroundColor(colors.black)
  45. moniT3.setBackgroundColor(colors.black)
  46.  
  47.  
  48.  
  49.  
  50. local valT0EA=turbina0.getEnergyStored()
  51. local valT0Vel=turbina0.getRotorSpeed()
  52. local valT0EP=turbina0.getEnergyProducedLastTick()
  53. local valT1EA=turbina1.getEnergyStored()
  54. local valT1Vel=turbina1.getRotorSpeed()
  55. local valT1EP=turbina1.getEnergyProducedLastTick()
  56.  
  57. local TurbX
  58. local TurbY
  59. local TurbText
  60. local TurbColor
  61. local PercBarColT0="white"
  62. local PercBarColT1="white"
  63. local EfecPaletasT0My=(paletasT0*25)+24
  64. local EfecPaletasT0Mn=(paletasT0*25)-24
  65. local EfecPaletasT1My=(paletasT1*25)+24
  66. local EfecPaletasT1Mn=(paletasT1*25)-24
  67.  
  68.  
  69. local function clon(TurbY,TurbX,TurbText, TurbColor)
  70.     local ColorT
  71.     if TurbColor=="red" then ColorT=colors.red end
  72.     if TurbColor=="blue" then ColorT=colors.blue end
  73.     if TurbColor=="orange" then ColorT=colors.orange end
  74.     if TurbColor=="white" then ColorT=colors.white end
  75.     if TurbColor=="black" then ColorT=colors.black end
  76.     if TurbColor=="green" then ColorT=colors.green end
  77.    
  78.     moniT1.setTextColor(ColorT)
  79.     moniT1.setCursorPos(TurbY, TurbX)
  80.     moniT1.write(TurbText)
  81.  
  82.     moniT2.setTextColor(ColorT)
  83.     moniT2.setCursorPos(TurbY, TurbX)
  84.     moniT2.write(TurbText)
  85. end
  86.  
  87. local function clon2V(TurbY,TurbX,Turb0Text,Turb1Text, TurbColor)
  88.     local ColorT
  89.     if TurbColor=="red" then ColorT=colors.red end
  90.     if TurbColor=="blue" then ColorT=colors.blue end
  91.     if TurbColor=="orange" then ColorT=colors.orange end
  92.     if TurbColor=="white" then ColorT=colors.white end
  93.     if TurbColor=="black" then ColorT=colors.black end
  94.     if TurbColor=="green" then ColorT=colors.green end
  95.     if TurbColor=="yellow" then ColorT=colors.yellow end
  96.    
  97.     moniT1.setTextColor(ColorT)
  98.     moniT1.setCursorPos(TurbY, TurbX)
  99.     moniT1.write(Turb0Text)
  100.  
  101.     moniT2.setTextColor(ColorT)
  102.     moniT2.setCursorPos(TurbY, TurbX)
  103.     moniT2.write(Turb1Text)
  104. end
  105.    
  106. local function TextPanta(SetX, SetY, SetText, SetColor, SetPanta, UseLenTBox, LenTBox)
  107.     local ColorT
  108.     if UseLenTBox==true then SetX=SetX-1 end   
  109.     if SetColor=="red" then ColorT=colors.red end
  110.     if SetColor=="blue" then ColorT=colors.blue end
  111.     if SetColor=="orange" then ColorT=colors.orange end
  112.     if SetColor=="white" then ColorT=colors.white end
  113.     if SetColor=="black" then ColorT=colors.black end
  114.     if SetColor=="green" then ColorT=colors.green end
  115.     if SetColor=="yellow" then ColorT=colors.yellow end
  116.     if SetPanta==1 then moniDef = peripheral.wrap(monitorT1Nombre) end
  117.     if SetPanta==2 then moniDef = peripheral.wrap(monitorT2Nombre) end
  118.     if SetPanta==3 then moniDef = peripheral.wrap(monitorT3Nombre) end
  119.  
  120.     moniDef.setTextColor(ColorT)
  121.     if UseLenTBox==false then
  122.         moniDef.setCursorPos(SetX, SetY)
  123.     else
  124.         moniDef.setCursorPos(SetX-string.len(SetText), SetY)
  125.     end
  126.     moniDef.write(SetText)
  127.    
  128.    
  129.    
  130.     if UseLenTBox == true then
  131.         if (LenTBox-string.len(SetText)) > 0 then
  132.             term.redirect(moniDef)
  133.             paintutils.drawLine(SetX-(LenTBox-1),SetY,((SetX-LenTBox)+(LenTBox-string.len(SetText)))-1,SetY,colors.black)
  134.             moniDef.setBackgroundColor(colors.black)
  135.         end
  136.     end
  137. end
  138.        
  139. local function DibuBar(SetX1,SetY1,SetX2,SetY2,SetColor, SetPanta)
  140.     local ColorT
  141.     if SetColor=="red" then ColorT=colors.red end
  142.     if SetColor=="blue" then ColorT=colors.blue end
  143.     if SetColor=="orange" then ColorT=colors.orange end
  144.     if SetColor=="white" then ColorT=colors.white end
  145.     if SetColor=="black" then ColorT=colors.black end
  146.     if SetColor=="green" then ColorT=colors.green end
  147.     if SetColor=="yellow" then ColorT=colors.yellow end
  148.     if SetPanta==1 then moniDef = peripheral.wrap(monitorT1Nombre) end
  149.     if SetPanta==2 then moniDef = peripheral.wrap(monitorT2Nombre) end
  150.     if SetPanta==3 then moniDef = peripheral.wrap(monitorT3Nombre) end
  151.    
  152.     term.redirect(moniDef)
  153.     paintutils.drawLine(SetX1,SetY1,SetX2,SetY2,ColorT)
  154.     moniDef.setBackgroundColor(colors.black)
  155.    
  156. end
  157.  
  158.  
  159.  
  160. local function DibujarPantalla()
  161.     moniT1.clear()
  162.     moniT2.clear()
  163.     moniT3.clear()
  164.  
  165.     moniT1.setBackgroundColor(colors.black)
  166.     moniT2.setBackgroundColor(colors.black)
  167.     moniT3.setBackgroundColor(colors.black)
  168.  
  169.     clon(14, 1, "--", "white")
  170.     clon(33, 1, "Nedrek", "orange")
  171.     clon(34, 2, "V1.1", "orange")
  172.    
  173.     TextPanta(14,1,"--","white",3,false)
  174.     TextPanta(76,1,"Nedrek","orange",3,false)
  175.     TextPanta(77,2,"V1.1","orange",3,false)
  176.  
  177.     DibuBar(1,3,39,3,"white",1)
  178.     DibuBar(1,3,39,3,"white",2)
  179.     DibuBar(1,3,82,3,"white",3)
  180.  
  181.     clon2V(4,1,"TURBINA 0", "TURBINA 1", "orange")
  182.     clon2V(3,2,turbina0Nombre, turbina1Nombre, "orange")
  183.    
  184.     TextPanta(6,1,"REACTOR", "orange", 3,false)
  185.     TextPanta(3,2,reactorNombre, "orange", 3,false)
  186.    
  187.     DibuBar(33,19,33,8,"white",3)
  188.     DibuBar(73,19,73,8,"white",3)
  189.     DibuBar(63,19,63,8,"white",3)
  190.     DibuBar(53,19,53,8,"white",3)
  191.     DibuBar(43,19,43,6,"white",3)
  192.     DibuBar(43,6,82,6,"white",3)
  193.     DibuBar(34,8,82,8,"white",3)
  194.     TextPanta(48,6," Control de nivel de los Rods ", "orange", 3,false)
  195.     TextPanta(36,8," Fuel", "orange", 3,false)
  196.    
  197. if (testEncendido[1] == true) then
  198.     TextPanta(17,1,"ONLINE ", "green", 1,false)
  199. else
  200.     TextPanta(17,1,"OFFLINE ", "red", 1, false)
  201. end
  202.  
  203. if (testEncendido[3] == true) then
  204.     TextPanta(17,1,"ONLINE ", "green", 2,false)
  205. else
  206.     TextPanta(17,1,"OFFLINE ", "red", 2, false)
  207. end
  208.  
  209. if (testEncendido[2] == true) then
  210.     TextPanta(17,1,"ONLINE ", "green", 3, false)
  211. else
  212.     TextPanta(17,1,"OFFLINE ", "red", 3, false)
  213. end
  214.  
  215.     clon(1, 4, "Energia Almacenada: ", "white")
  216.     clon(1, 5, "Velocidad: ", "white")
  217.     clon(1, 6, "Energia Producida: ", "white")
  218.     clon(11, 8, "Vapor en tanque: ", "white")
  219.     clon(11, 9, "Agua en tanque: ", "white")
  220.     clon(11, 10, "Entrada: ", "white")
  221.     clon(24, 15, "+ Entrada", "white")
  222.     clon(12, 16, "1 10 99 1K", "white")
  223.     clon(24, 17, "- Entrada", "white")
  224.     clon(14, 19, "Encender/Apagar", "white")
  225.     TextPanta(5,19, "Encender/Apagar", "white", 3, false)
  226.  
  227.     clon(35, 4, "RF", "red")
  228.     clon(35, 5, "RPM", "red")
  229.     clon(35, 6, "RF/T", "red")
  230.     clon(35, 8, "mb", "red")
  231.     clon(35, 9, "mb", "red")
  232.     clon(35, 10, "mb/t", "red")
  233.    
  234.     TextPanta(1,6,"Temp Nucleo: ", "white", 3, false)
  235.     TextPanta(1,8,"Temp Exterior: ", "white", 3, false)
  236.     TextPanta(1,10,"Combustible: ", "white", 3, false)
  237.     TextPanta(1,11,"Desechos: ", "white", 3, false)
  238.     TextPanta(1,12,"Consumo : ", "white", 3, false)
  239.     TextPanta(1,13,"Agua en tanque: ", "white", 3, false)
  240.     TextPanta(1,14,"Vapor en tanque: ", "white", 3, false)
  241.     TextPanta(1,15,"Eficiencia: ", "white", 3, false)
  242.     TextPanta(1,16,"Uso del Nucleo: ", "white", 3, false)
  243.     TextPanta(1,17,"Agotamiento Nucleo: ", "white", 3, false)
  244.    
  245.    
  246.     TextPanta(29,6,"C", "red", 3, false)
  247.     TextPanta(29,8,"C", "red", 3, false)
  248.     TextPanta(29,10,"mb", "red", 3, false)
  249.     TextPanta(29,11,"mb", "red", 3, false)
  250.     TextPanta(29,12,"mb/t", "red", 3, false)
  251.     TextPanta(29,13,"mb", "red", 3, false)
  252.     TextPanta(29,14,"mb", "red", 3, false)
  253.     TextPanta(29,15,"%", "red", 3, false)
  254.     TextPanta(29,16,"%", "red", 3, false)
  255.     TextPanta(29,17,"%", "red", 3, false)
  256.  
  257.    
  258.    
  259.            
  260.     for i=2, 12 do
  261.         local CP
  262.         --if (i==1) then CP="red"   else if (i==2) then CP="green" else CP="blue" end end
  263.         --clon(4, i+7, perc[i], CP)
  264.         TextPanta(37,i+7,perc[i], "green", 3, false)
  265.         TextPanta(47,i+7,perc[i], "blue", 3, false)
  266.         TextPanta(57,i+7,perc[i], "blue", 3, false)
  267.         TextPanta(67,i+7,perc[i], "blue", 3, false)
  268.         TextPanta(77,i+7,perc[i], "blue", 3, false)
  269.     end
  270.    
  271.     for i=1, 12 do
  272.         local CP
  273.         if (i==1) then CP="red" else if (i==2) then CP="green" else CP="blue" end end
  274.         clon(4, i+7, perc[i], CP)
  275.     end
  276.    
  277.     for b=15,17,2 do
  278.         for a=11,20,3 do
  279.             DibuBar(a,b,a+1,b,"blue",1)        
  280.         end
  281.     end
  282.     DibuBar(11,19,12,19,"blue",1)
  283.    
  284.     for b=15,17,2 do
  285.         for a=11,20,3 do
  286.             DibuBar(a,b,a+1,b,"blue",2)
  287.         end
  288.     end
  289.     DibuBar(11,19,12,19,"blue",2)
  290.    
  291.     DibuBar(2,19,3,19,"blue",3)
  292.  
  293.    
  294.     DibuBar(((paletasT0*25)/74)+11,12,((paletasT0*25)/74)+11,12,"green",1)
  295.     DibuBar(11,12,((paletasT0*25)/74)+10,12,"blue",1)
  296.     DibuBar(((paletasT0*25)/74)+12,12,38,12,"red",1)
  297.    
  298.     DibuBar(((paletasT1*25)/74)+11,12,((paletasT1*25)/74)+11,12,"green",2)
  299.     DibuBar(11,12,((paletasT1*25)/74)+10,12,"blue",2)
  300.     DibuBar(((paletasT1*25)/74)+12,12,38,12,"red",2)
  301.    
  302. end
  303.  
  304. local function round(num)
  305.     i, j = string.find(num, '.', 1, true)
  306.     if i==nil then
  307.         num=num..".00"
  308.     else
  309.         if i==string.len(num)-1 then
  310.             num=num.."0"  
  311.         else
  312.             num=string.sub(num,1,i+2)
  313.         end
  314.     end
  315.  
  316.    
  317. --  TextPanta(1,17,num, "blue", 3, false)
  318.    
  319.     return num
  320. end
  321.  
  322.  
  323.  function DibPant ()
  324.     while not finished do
  325.     sleep(0)
  326.         local valT0EA=turbina0.getEnergyStored()
  327.         local valT0Vel=turbina0.getRotorSpeed()
  328.         local valT0EP=turbina0.getEnergyProducedLastTick()
  329.         local valT0VPT=turbina0.getInputAmount()
  330.         local valT0VTS=turbina0.getOutputAmount()
  331.         local valT0VSM=turbina0.getFluidFlowRate()
  332.        
  333.         local valT1EA=turbina1.getEnergyStored()
  334.         local valT1Vel=turbina1.getRotorSpeed()
  335.         local valT1EP=turbina1.getEnergyProducedLastTick()
  336.         local valT1VPT=turbina1.getInputAmount()
  337.         local valT1VTS=turbina1.getOutputAmount()
  338.         local valT1VSM=turbina1.getFluidFlowRate()
  339.        
  340.         local valReactorCoreHeat=reactor0.getFuelTemperature()
  341.         local valReactorCasingHeat=reactor0.getCasingTemperature()
  342.         local valReactorFuelA=reactor0.getFuelAmount()
  343.         local valReactorFuelW=reactor0.getWasteAmount()
  344.         local valReactorFuelCLT=reactor0.getFuelConsumedLastTick()
  345.         local valReactorCA=reactor0.getCoolantAmount()
  346.         local valReactorHFA=reactor0.getHotFluidAmount()
  347.         local valReactorFuelR=reactor0.getFuelReactivity()
  348.         local valReactorFuelMax=reactor0.getFuelAmountMax()
  349.          
  350.                
  351.         local valReactorCR0=reactor0.getControlRodName(0)
  352.         local valReactorCR1=reactor0.getControlRodName(1)
  353.         local valReactorCR2=reactor0.getControlRodName(2)
  354.         local valReactorCR3=reactor0.getControlRodName(3)
  355.         local valReactorCR0L=reactor0.getControlRodLevel(0)
  356.         local valReactorCR1L=reactor0.getControlRodLevel(1)
  357.         local valReactorCR2L=reactor0.getControlRodLevel(2)
  358.         local valReactorCR3L=reactor0.getControlRodLevel(3)
  359.        
  360.        
  361.                
  362.         local dibBarraT1 = 19-(valT0Vel/185)
  363.         local dibBarraT2 = 19-(valT1Vel/185)
  364.        
  365.         DibuBar(2,7,2,dibBarraT1-1,"black",1)
  366.         DibuBar(2,19,2,dibBarraT1,"blue",1)
  367.        
  368.         DibuBar(2,7,2,dibBarraT2-1,"black",2)
  369.         DibuBar(2,19,2,dibBarraT2,"blue",2)
  370.        
  371.         local PercVapT0=(valT0VSM/74)+10
  372.         local PercVapT1=(valT1VSM/74)+10
  373.                
  374.         if valT0VSM<EfecPaletasT0My then PercBarColT0="blue" end
  375.         if valT0VSM>EfecPaletasT0My then PercBarColT0="red" end
  376.         if valT0VSM>=EfecPaletasT0My and valT0VSM<=EfecPaletasT0My then PercBarColT0="green" end
  377.        
  378.         if valT1VSM<EfecPaletasT1My then PercBarColT1="blue" end
  379.         if valT1VSM>EfecPaletasT1My then PercBarColT1="red" end
  380.         if valT1VSM>=EfecPaletasT1My and valT0VSM<=EfecPaletasT1My then PercBarColT1="green" end
  381.        
  382.         if PercVapT0<=11 then PercVapT0=11 end
  383.         if PercVapT0>=38 then PercVapT0=38 end
  384.        
  385.         if PercVapT1<=11 then PercVapT1=11 end
  386.         if PercVapT1>=38 then PercVapT1=38 end
  387.        
  388.         DibuBar(11,13,PercVapT0,13,PercBarColT0,1)
  389.         DibuBar(39,13,PercVapT0+1,13,"black",1)
  390.        
  391.         DibuBar(11,13,PercVapT1,13,PercBarColT1,2)
  392.         DibuBar(39,13,PercVapT1+1,13,"black",2)
  393.            
  394.  
  395.         TextPanta(35, 4,round(valT0EA), "green", 1, true, 9)
  396.         TextPanta(35, 4,round(valT1EA), "green", 2, true, 9)
  397.         TextPanta(35, 5,round(valT0Vel), "green", 1, true, 9)
  398.         TextPanta(35, 5,round(valT1Vel), "green", 2, true, 9)
  399.         TextPanta(35, 6,round(valT0EP), "green", 1, true, 9)
  400.         TextPanta(35, 6,round(valT1EP), "green", 2, true, 9)
  401.         TextPanta(35, 8,round(valT0VPT), "green", 1, true, 6)
  402.         TextPanta(35, 8,round(valT1VPT), "green", 2, true, 6)
  403.         TextPanta(35, 9,round(valT0VTS), "green", 1, true, 9)
  404.         TextPanta(35, 9,round(valT1VTS), "green", 2, true, 9)
  405.         TextPanta(35, 10,round(valT0VSM), "green", 1, true, 9)
  406.         TextPanta(35, 10,round(valT1VSM), "green", 2, true, 9)
  407.        
  408.         TextPanta(29, 6,round(valReactorCoreHeat), "green", 3, true, 12)
  409.         TextPanta(29, 8,round(valReactorCasingHeat), "green", 3, true,12)
  410.         TextPanta(29, 10,round(valReactorFuelA), "green", 3, true, 12)
  411.         TextPanta(29, 11,round(valReactorFuelW), "green", 3, true, 12)
  412.         TextPanta(29, 12,round(valReactorFuelCLT), "green", 3, true, 12)
  413.         TextPanta(29, 13,round(valReactorCA), "green", 3, true, 12)
  414.         TextPanta(29, 14,round(valReactorHFA), "green", 3, true, 12)
  415.         TextPanta(29, 15,round(valReactorFuelR), "green", 3, true, 12)
  416.         TextPanta(29, 16,round((100/valReactorFuelMax)*(valReactorFuelA+valReactorFuelW)), "green", 3, true, 12)
  417.         TextPanta(29, 17,round((100/(valReactorFuelA+valReactorFuelW))*(valReactorFuelW)), "green", 3, true, 8)
  418.                
  419.         TextPanta(45, 8," "..valReactorCR0, "green", 3, false)
  420.         TextPanta(55, 8," "..valReactorCR1, "green", 3, false)
  421.         TextPanta(65, 8," "..valReactorCR2, "green", 3, false)
  422.         TextPanta(75, 8," "..valReactorCR3, "green", 3, false)
  423.        
  424.        
  425.         DibuBar(45,19,45,19-(valReactorCR0L/10),"blue",3)
  426.         DibuBar(55,19,55,19-(valReactorCR1L/10),"blue",3)
  427.         DibuBar(65,19,65,19-(valReactorCR2L/10),"blue",3)
  428.         DibuBar(75,19,75,19-(valReactorCR3L/10),"blue",3)
  429.         if valReactorCR0L ~= 100 then DibuBar(45,9,45,(19-(valReactorCR0L/10))-1,"black",3) end
  430.         if valReactorCR1L ~= 100 then DibuBar(55,9,55,(19-(valReactorCR1L/10))-1,"black",3) end
  431.         if valReactorCR2L ~= 100 then DibuBar(65,9,65,(19-(valReactorCR2L/10))-1,"black",3) end
  432.         if valReactorCR3L ~= 100 then DibuBar(75,9,75,(19-(valReactorCR3L/10))-1,"black",3) end
  433.        
  434.        
  435.        
  436.         local PercHeatCore=((28/2000)*math.ceil(round(valReactorCoreHeat)))
  437.         local PercHeatCasing=((28/2000)*math.ceil(round(valReactorCasingHeat)))
  438.         if PercHeatCore<=30 then
  439.             if PercHeatCore>=19 then
  440.                 DibuBar(2,7,20,7,"green",3)
  441.                 DibuBar(21,7,PercHeatCore+2,7,"red",3)         
  442.             else
  443.                 DibuBar(2,7,PercHeatCore+2,7,"green",3)        
  444.             end
  445.             DibuBar(PercHeatCore+3,7,31,7,"black",3)
  446.         end
  447.         if PercHeatCasing<=30 then
  448.             if PercHeatCasing>=19 then
  449.                 DibuBar(2,9,20,9,"green",3)
  450.                 DibuBar(21,9,PercHeatCasing+2,9,"red",3)           
  451.             else
  452.                 DibuBar(2,9,PercHeatCasing+2,9,"green",3)          
  453.             end
  454.             DibuBar(PercHeatCasing+3,9,31,9,"black",3)
  455.         end
  456.        
  457.  
  458.         local Desechos= math.ceil(round((100/valReactorFuelMax)*valReactorFuelW)/10)
  459.         local Combus= math.ceil(round((100/valReactorFuelMax)*valReactorFuelA)/10)
  460.        
  461.         if Desechos~=0 then DibuBar(35,19,35,(19-Desechos)+1,"blue",3) end
  462.         if Combus~=0 then DibuBar(35,(19-Desechos),35,(19-Desechos)-Combus+1,"green",3) end
  463.  
  464.        
  465.         local PecVeloT0=math.ceil((100/1800)*valT0Vel)
  466.         local PecVeloT1=math.ceil((100/1800)*valT1Vel)
  467.        
  468.         TextPanta(18, 5,PecVeloT0.."%", "green", 1, true, 6)
  469.         TextPanta(18, 5,PecVeloT1.."%", "green", 2, true, 6)
  470.     end
  471.  end
  472.  
  473. function MoniTouch ()
  474.     while not finished do
  475.         local onoff = "nook"
  476.         local Flowplus = 0
  477.         local RodF=0
  478.         local SetRod=5
  479.                 event, Monitor, w, h = os.pullEvent("monitor_touch")
  480.         if Monitor == monitorT3Nombre then
  481.             if (w>=2 and w<=3) and h==19 then   onoff="ok" end
  482.            
  483.             if w==45 then RodF=0 end
  484.             if w==55 then RodF=1 end
  485.             if w==65 then RodF=2 end
  486.             if w==75 then RodF=3 end
  487.            
  488.             if RodF ~= 5 then
  489.                 SetRod=(19-h)*10
  490.                 --TextPanta(1,18    ,SetRod.." "..RodF, "blue", 3, false)
  491.                 if SetRod<=100 then reactor0.setControlRodLevel(RodF,SetRod) end
  492.            
  493.             end
  494.            
  495.            
  496.        
  497.         else
  498.             if (w>=11 and w<=12) and h==19 then onoff="ok" end
  499.             if (w>=11 and w<=12) and h==17 then Flowplus=1999 end
  500.             if (w>=14 and w<=15) and h==17 then Flowplus=1990 end
  501.             if (w>=17 and w<=18) and h==17 then Flowplus=1900 end
  502.             if (w>=20 and w<=21) and h==17 then Flowplus=1000 end
  503.        
  504.             if (w>=11 and w<=12) and h==15 then Flowplus=2001 end
  505.             if (w>=14 and w<=15) and h==15 then Flowplus=2010 end
  506.             if (w>=17 and w<=18) and h==15 then Flowplus=2100 end
  507.             if (w>=20 and w<=21) and h==15 then Flowplus=3000 end
  508.         end
  509.        
  510.         if Flowplus>=1 then
  511.             if (Monitor==monitorT1Nombre) then
  512.                 local Flow=(tonumber(turbina0.getFluidFlowRate())+Flowplus)-2000
  513.                 if Flow>=2000 then Flow=2000 end
  514.                 if Flow<=1 then Flow=1 end
  515.                 turbina0.setFluidFlowRateMax(Flow)
  516.             end
  517.             if (Monitor==monitorT2Nombre) then
  518.        
  519.             end
  520.         end
  521.        
  522.         if onoff == "ok" then
  523.             if (Monitor==monitorT1Nombre) then
  524.                 if (testEncendido[1]==true) then
  525.                     turbina0.setActive(false)
  526.                     testEncendido[1]=false
  527.                     TextPanta(17,1,"OFFLINE ", "red", 1, false)
  528.                 else
  529.                     turbina0.setActive(true)
  530.                     testEncendido[1]=true
  531.                     TextPanta(17,1,"ONLINE ", "green", 1, false)
  532.                 end
  533.             end
  534.             if (Monitor==monitorT2Nombre) then
  535.                 if (testEncendido[3]==true) then
  536.                     turbina1.setActive(false)
  537.                     testEncendido[3]=false
  538.                     TextPanta(17,1,"OFFLINE ", "red", 2, false)
  539.                 else
  540.                     turbina1.setActive(true)
  541.                     testEncendido[3]=true
  542.                     TextPanta(17,1,"ONLINE ", "green", 2, false)
  543.                 end
  544.             end
  545.             if (Monitor==monitorT3Nombre) then
  546.                 if (testEncendido[2]==true) then
  547.                     reactor0.setActive(false)
  548.                     testEncendido[2]=false
  549.                     TextPanta(17,1,"OFFLINE ", "red", 3, false)
  550.                 else
  551.                     reactor0.setActive(true)
  552.                     testEncendido[2]=true
  553.                     TextPanta(17,1,"ONLINE ", "green", 3, false)
  554.                 end
  555.             end
  556.         end
  557.     end
  558. end
  559.  
  560. DibujarPantalla()
  561.  
  562. while not finished do
  563.         parallel.waitForAny(MoniTouch, DibPant)
  564.         sleep(EsperaBucle)
  565.  
  566. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement