BigBlow_

FusionReactorMonitor

Mar 16th, 2025 (edited)
737
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 23.33 KB | None | 0 0
  1. -- Configuration
  2. local reactor_name = "fusionReactorLogicAdapter_0"  -- Modem : Name of the reactor modem
  3. local alarm_side = "top"    -- Redstone : Face to send redstone if reactor is off
  4. local alarm_side2 = "front"  -- Redstone : Additional face to send redstone when reactor is off
  5. local ignitSide = "left"   -- Redstone : Face to send pulse to start the reactor
  6. local ignitPulseTime = 1         -- Duration of the pulse in seconds
  7.  
  8. local function timestamp()
  9.     return os.date("[%d-%m %H:%M:%S] ")  -- Format: [DD-MM HH:MM:SS]
  10. end
  11.  
  12. -- Startup animation for console
  13. local function showStartupAnimation()
  14.     term.clear()
  15.     term.setCursorPos(1,1)
  16.    
  17.     print("    Fusion Reactor Controler by Le_Jiww")
  18.     print("    [Developed for my bro: BigBlow]")
  19.     print("")
  20.    
  21.     -- Loading animation
  22.     io.write("    System initialization")
  23.     for i = 1, 5 do
  24.         io.write(".")
  25.         sleep(0.2)
  26.     end
  27.     print("\n")
  28.     sleep(0.5)
  29.    
  30.     -- Display startup information
  31.     print(timestamp() .. "    > Connecting to fusion reactor...")
  32.     sleep(0.3)
  33.     print(timestamp() .. "    > Initializing monitor...")
  34.     sleep(0.3)
  35.     print(timestamp() .. "    > Configuring redstone signals...")
  36.     sleep(0.5)
  37.     print(timestamp() .. "\n    [SYSTEM READY]")
  38.     print(timestamp() .. "\n    Reactor monitoring in progress...\n")
  39. end
  40.  
  41. -- Execute startup animation
  42. showStartupAnimation()
  43.  
  44. -- Monitor initialization
  45. local monitor = peripheral.find("monitor")
  46. if not monitor then
  47.     error("No monitor detected")
  48. end
  49.  
  50. -- Get screen dimensions
  51. local screen_width, screen_height = monitor.getSize()
  52.  
  53. -- Reactor initialization
  54. local reactor = peripheral.wrap(reactor_name)
  55. if not reactor then
  56.     error("Reactor not detected: " .. reactor_name)
  57. end
  58. monitor.clear()
  59. monitor.setTextScale(1)
  60. monitor.setTextColor(colors.white)
  61.  
  62. -- Button coordinates (adjusted for better central position)
  63. local button_x1, button_y1 = 12, 12  -- Center position and lower down
  64. local button_x2, button_y2 = 28, 15
  65.  
  66. -- Tracking variables
  67. local last_ignited = nil
  68. local ignition_in_progress = false  -- Prevents double sending the signal
  69. local animation_frame = 0
  70. local pulse_animation = 0  -- Pulsing animation for activity indicator
  71. local rotation_animation = 0  -- Rotation animation for activity indicator
  72.  
  73. -- Function to format numbers with spaces
  74. local function formatNumber(n)
  75.     return tostring(n):reverse():gsub("(%d%d%d)", "%1 "):reverse():gsub("^ ", "")
  76. end
  77.  
  78. -- Function to format large numbers with K, M, G, etc.
  79. local function formatCompact(n)
  80.     if n >= 1000000000 then
  81.         return string.format("%.2fG", n / 1000000000)
  82.     elseif n >= 1000000 then
  83.         return string.format("%.2fM", n / 1000000)
  84.     elseif n >= 1000 then
  85.         return string.format("%.2fK", n / 1000)
  86.     else
  87.         return string.format("%.1f", n)
  88.     end
  89. end
  90.  
  91. -- Characters for rotation animation
  92. local rotation_chars = {"|", "/", "-", "\\"}
  93.  
  94. -- Function to update only the values (without redrawing the frames)
  95. local function updateReactorValues()
  96.     if not reactor.isIgnited() then return end
  97.    
  98.     -- Get reactor data
  99.     local production = reactor.getProductionRate()
  100.     local productionRF = production / 2.5
  101.    
  102.     -- Variables for additional data
  103.     local plasmaTemp, caseTemp, injectionRate, efficiency, fuel = nil, nil, nil, nil, nil
  104.    
  105.     -- Try to get plasma temperature
  106.     local success, result = pcall(function() return reactor.getPlasmaTemperature() end)
  107.     if success and result then plasmaTemp = result end
  108.    
  109.     -- Try to get case temperature
  110.     success, result = pcall(function() return reactor.getCaseTemperature() end)
  111.     if success and result then caseTemp = result end
  112.    
  113.     -- Try to get injection rate
  114.     success, result = pcall(function() return reactor.getInjectionRate() end)
  115.     if success and result then injectionRate = result end
  116.    
  117.     -- Try to get efficiency
  118.     success, result = pcall(function() return reactor.getEfficiency() end)
  119.     if success and result then
  120.         efficiency = result
  121.     else
  122.         efficiency = math.min(98.5, 50 + productionRF / 50000)
  123.     end
  124.    
  125.     -- Try to get fuel
  126.     success, result = pcall(function() return reactor.getFuel() end)
  127.     if success and result then fuel = result end
  128.    
  129.     -- Update values only (not labels)
  130.     monitor.setBackgroundColor(colors.black)
  131.    
  132.     -- Update activity indicator (rotation animation)
  133.     rotation_animation = (rotation_animation + 1) % 4
  134.     local rotation_char = rotation_chars[rotation_animation + 1]
  135.    
  136.     monitor.setCursorPos(screen_width - 4, 2)
  137.     monitor.setTextColor(colors.lime)
  138.     monitor.write(rotation_char)
  139.    
  140.     -- 1. Energy production (update value only with slight variation for animation)
  141.     local variation = math.random(-15, 15) / 10  -- Random variation of ±1.5%
  142.     local displayedRF = productionRF * (1 + variation/100)
  143.    
  144.     monitor.setCursorPos(20, 10)
  145.     monitor.setTextColor(colors.yellow)
  146.     monitor.write(formatCompact(displayedRF).." RF/t    ")
  147.    
  148.     -- 2. Efficiency (update value only with slight variation)
  149.     local effVariation = math.random(-2, 2) / 10  -- Random variation of ±0.2%
  150.     local displayedEff = efficiency + effVariation
  151.    
  152.     monitor.setCursorPos(20, 11)
  153.     monitor.setTextColor(colors.yellow)
  154.     monitor.write(string.format("%.1f%%    ", displayedEff))
  155.    
  156.     -- Efficiency bar animation (pulsation)
  157.     local bar_length = 18
  158.     pulse_animation = (pulse_animation + 0.2) % 10
  159.     local pulse_factor = 1 + math.sin(pulse_animation) * 0.05  -- Pulsing variation of ±5%
  160.     local bar_progress = math.min(1, (productionRF * pulse_factor) / 1000000)
  161.     local filled_length = math.floor(bar_progress * bar_length)
  162.    
  163.     monitor.setCursorPos(13, 12)
  164.     for i = 1, bar_length do
  165.         if i <= filled_length then
  166.             if i >= bar_length - 1 and pulse_animation > 5 then
  167.                 monitor.setBackgroundColor(colors.yellow)  -- Flashing overload effect
  168.             else
  169.                 monitor.setBackgroundColor(colors.lime)
  170.             end
  171.             monitor.write(" ")
  172.         else
  173.             monitor.setBackgroundColor(colors.gray)
  174.             monitor.write(" ")
  175.         end
  176.     end
  177.     monitor.setBackgroundColor(colors.black)
  178.    
  179.     -- 3. Plasma temperature (if available, with animation)
  180.     if plasmaTemp then
  181.         local tempVariation = math.random(-50, 50) / 10  -- Random variation of ±5
  182.         local displayedTemp = plasmaTemp / 1000000 + tempVariation/100
  183.        
  184.         monitor.setCursorPos(20, 13)
  185.         monitor.setTextColor(colors.orange)
  186.         monitor.write(string.format("%.2f MK    ", displayedTemp))
  187.     end
  188.    
  189.     -- 4. Injection rate (if available, with slight variation)
  190.     if injectionRate then
  191.         local injVariation = math.random(-5, 5)  -- Random variation of ±5
  192.         monitor.setCursorPos(20, 14)
  193.         monitor.setTextColor(colors.yellow)
  194.         monitor.write(string.format("%d mB/t       ", injectionRate + injVariation))
  195.     end
  196.    
  197.     -- 5. Fuel (if available, with simulated consumption)
  198.     if fuel then
  199.         monitor.setCursorPos(20, 15)
  200.         monitor.setTextColor(colors.yellow)
  201.         monitor.write(string.format("%d mB       ", fuel))
  202.     end
  203.    
  204.     -- Reset colors
  205.     monitor.setBackgroundColor(colors.black)
  206.     monitor.setTextColor(colors.white)
  207. end
  208.  
  209. -- Definition of characters for borders
  210. local h_line = "\140"  -- Horizontal line
  211. local v_line = "\149"  -- Vertical line
  212. local tl_corner = "\151"  -- Top left corner
  213. local tr_corner = "\152"  -- Top right corner
  214. local bl_corner = "\154"  -- Bottom left corner
  215. local br_corner = "\153"  -- Bottom right corner
  216.  
  217. -- Function to draw a box with border
  218. local function drawBox(x1, y1, x2, y2, bg_color, border_color)
  219.     monitor.setBackgroundColor(bg_color or colors.black)
  220.     monitor.setTextColor(border_color or colors.cyan)
  221.    
  222.     -- Corners
  223.     monitor.setCursorPos(x1, y1)
  224.     monitor.write(tl_corner)
  225.     monitor.setCursorPos(x2, y1)
  226.     monitor.write(tr_corner)
  227.     monitor.setCursorPos(x1, y2)
  228.     monitor.write(bl_corner)
  229.     monitor.setCursorPos(x2, y2)
  230.     monitor.write(br_corner)
  231.    
  232.     -- Horizontal lines
  233.     for x = x1 + 1, x2 - 1 do
  234.         monitor.setCursorPos(x, y1)
  235.         monitor.write(h_line)
  236.         monitor.setCursorPos(x, y2)
  237.         monitor.write(h_line)
  238.     end
  239.    
  240.     -- Vertical lines
  241.     for y = y1 + 1, y2 - 1 do
  242.         monitor.setCursorPos(x1, y)
  243.         monitor.write(v_line)
  244.         monitor.setCursorPos(x2, y)
  245.         monitor.write(v_line)
  246.     end
  247.    
  248.     -- Interior
  249.     monitor.setBackgroundColor(bg_color or colors.black)
  250.     for y = y1 + 1, y2 - 1 do
  251.         monitor.setCursorPos(x1 + 1, y)
  252.         for x = x1 + 1, x2 - 1 do
  253.             monitor.write(" ")
  254.         end
  255.     end
  256. end
  257.  
  258. -- Function to draw a centered title in a box
  259. local function drawTitle(text, x1, x2, y, color)
  260.     local width = x2 - x1 - 1
  261.     local text_x = x1 + math.floor((width - #text) / 2) + 1
  262.    
  263.     monitor.setTextColor(color or colors.yellow)
  264.     monitor.setCursorPos(text_x, y)
  265.     monitor.write(text)
  266.     monitor.setTextColor(colors.white)
  267. end
  268.  
  269. -- Function to display information
  270. local function displayInfo()
  271.     local ignited = reactor.isIgnited()
  272.     local should_redraw = (last_ignited ~= ignited) or (not last_ignited)
  273.    
  274.     -- Only animate the status icon, not the entire screen
  275.     animation_frame = (animation_frame + 1) % 8
  276.    
  277.     -- Avoid redrawing the entire screen each time
  278.     if not should_redraw then
  279.         -- Selective update for animated elements only
  280.         if ignited then
  281.             -- Update only the flashing status with a more visible animation
  282.             monitor.setCursorPos(13, 5)
  283.             if animation_frame < 4 then
  284.                 monitor.setTextColor(colors.lime)
  285.                 monitor.write("IGNITED ")
  286.                 monitor.setTextColor(colors.yellow)
  287.                 monitor.write("*")
  288.             else
  289.                 monitor.setTextColor(colors.green)
  290.                 monitor.write("IGNITED ")
  291.                 monitor.setTextColor(colors.orange)
  292.                 monitor.write("+")
  293.             end
  294.            
  295.             -- Rotation animation in the upper right corner
  296.             monitor.setCursorPos(screen_width - 4, 2)
  297.             monitor.setTextColor(colors.lime)
  298.             monitor.write(rotation_chars[(rotation_animation + 1) % 4 + 1])
  299.            
  300.             -- Update data without clearing the entire screen
  301.             updateReactorValues()
  302.             return
  303.         end
  304.     end
  305.    
  306.     -- Otherwise, redraw the entire screen
  307.     monitor.clear()
  308.    
  309.     -- Big frame surrounding the entire screen
  310.     drawBox(1, 1, screen_width, screen_height, colors.black, colors.blue)
  311.    
  312.     -- Title at the top with styling
  313.     drawTitle("FUSION REACTOR CONTROL", 1, screen_width, 2, colors.yellow)
  314.    
  315.     -- Rotation animation in the upper right corner (program activity indicator)
  316.     monitor.setCursorPos(screen_width - 4, 2)
  317.     monitor.setTextColor(colors.lime)
  318.     monitor.write(rotation_chars[(animation_frame % 4) + 1])
  319.    
  320.     -- Status box
  321.     drawBox(3, 4, screen_width - 3, 6, colors.black, colors.cyan)
  322.     drawTitle("REACTOR STATUS", 3, screen_width - 3, 4, colors.white)
  323.    
  324.     monitor.setCursorPos(5, 5)
  325.     monitor.write("Status:")
  326.    
  327.     monitor.setCursorPos(13, 5)
  328.     if ignited then
  329.         -- Flashing animation for "IGNITED"
  330.         if animation_frame < 4 then
  331.             monitor.setTextColor(colors.lime)
  332.             monitor.write("IGNITED ")
  333.             monitor.setTextColor(colors.yellow)
  334.             monitor.write("*")
  335.         else
  336.             monitor.setTextColor(colors.green)
  337.             monitor.write("IGNITED ")
  338.             monitor.setTextColor(colors.orange)
  339.             monitor.write("+")
  340.         end
  341.         redstone.setOutput(alarm_side, false)  -- Disable redstone on primary face
  342.         redstone.setOutput(alarm_side2, false)  -- Disable redstone on secondary face
  343.         ignition_in_progress = false  -- Reset state after ignition
  344.     else
  345.         monitor.setTextColor(colors.red)
  346.         monitor.write("STOPPED")
  347.         redstone.setOutput(alarm_side, true)  -- Enable redstone on primary face
  348.         redstone.setOutput(alarm_side2, true)  -- Enable redstone on secondary face
  349.     end
  350.    
  351.     -- Reset color to white
  352.     monitor.setTextColor(colors.white)
  353.    
  354.     if ignited then
  355.         -- Energy production box
  356.         drawBox(3, 8, screen_width - 3, 16, colors.black, colors.cyan)
  357.         monitor.setTextColor(colors.white)
  358.         drawTitle("REACTOR TELEMETRY", 3, screen_width - 3, 8, colors.white)
  359.        
  360.         -- Get reactor data
  361.         local production = reactor.getProductionRate()
  362.         local productionRF = production / 2.5 -- Convert J to RF
  363.        
  364.         -- Let's try to get additional data (with error protection)
  365.         local plasmaTemp, caseTemp, injectionRate, efficiency, fuel = nil, nil, nil, nil, nil
  366.        
  367.         -- Try to get temperature (may not be available depending on version)
  368.         local success, result = pcall(function() return reactor.getPlasmaTemperature() end)
  369.         if success and result then plasmaTemp = result end
  370.        
  371.         -- Try to get case temperature
  372.         success, result = pcall(function() return reactor.getCaseTemperature() end)
  373.         if success and result then caseTemp = result end
  374.        
  375.         -- Try to get injection rate
  376.         success, result = pcall(function() return reactor.getInjectionRate() end)
  377.         if success and result then injectionRate = result end
  378.        
  379.         -- Try to get efficiency
  380.         success, result = pcall(function() return reactor.getEfficiency() end)
  381.         if success and result then
  382.             efficiency = result
  383.         else
  384.             -- Simulate an efficiency value based on production
  385.             efficiency = math.min(98.5, 50 + productionRF / 50000)
  386.         end
  387.        
  388.         -- Try to get fuel
  389.         success, result = pcall(function() return reactor.getFuel() end)
  390.         if success and result then fuel = result end
  391.        
  392.         -- Display data
  393.         local line = 0
  394.        
  395.         -- 1. Energy production (with slight variation for animation)
  396.         line = 10
  397.         monitor.setCursorPos(5, line)
  398.         monitor.write("Generation:")
  399.         monitor.setCursorPos(20, line)
  400.         monitor.setTextColor(colors.yellow)
  401.         -- Add a slight variation to give the impression of change
  402.         local variation = math.random(-15, 15) / 10  -- Random variation of ±1.5%
  403.         local displayedRF = productionRF * (1 + variation/100)
  404.         monitor.write(formatCompact(displayedRF).." RF/t")
  405.        
  406.         -- 2. Efficiency (with slight variation)
  407.         line = 11
  408.         monitor.setCursorPos(5, line)
  409.         monitor.setTextColor(colors.white)
  410.         monitor.write("Efficiency:")
  411.         monitor.setCursorPos(20, line)
  412.         monitor.setTextColor(colors.yellow)
  413.         local effVariation = math.random(-2, 2) / 10  -- Random variation of ±0.2%
  414.         monitor.write(string.format("%.1f%%", efficiency + effVariation))
  415.        
  416.         -- Visual production bar (with pulsation effect)
  417.         line = 12
  418.         monitor.setCursorPos(5, line)
  419.         monitor.setTextColor(colors.white)
  420.         monitor.write("Output:")
  421.        
  422.         local bar_length = 18
  423.         pulse_animation = (pulse_animation + 0.2) % 10
  424.         local pulse_factor = 1 + math.sin(pulse_animation) * 0.05  -- Pulsing variation of ±5%
  425.         local bar_progress = math.min(1, (productionRF * pulse_factor) / 1000000) -- Scale to adjust
  426.         local filled_length = math.floor(bar_progress * bar_length)
  427.        
  428.         monitor.setCursorPos(13, line)
  429.         for i = 1, bar_length do
  430.             if i <= filled_length then
  431.                 if i >= bar_length - 1 and pulse_animation > 5 then
  432.                     monitor.setBackgroundColor(colors.yellow)  -- Flashing overload effect
  433.                 else
  434.                     monitor.setBackgroundColor(colors.lime)
  435.                 end
  436.                 monitor.write(" ")
  437.             else
  438.                 monitor.setBackgroundColor(colors.gray)
  439.                 monitor.write(" ")
  440.             end
  441.         end
  442.         monitor.setBackgroundColor(colors.black)
  443.        
  444.         -- 3. Plasma temperature (if available, with animation)
  445.         if plasmaTemp then
  446.             line = 13
  447.             monitor.setCursorPos(5, line)
  448.             monitor.setTextColor(colors.white)
  449.             monitor.write("Plasma Temp:")
  450.             monitor.setCursorPos(20, line)
  451.             monitor.setTextColor(colors.orange)
  452.             -- Add a variation to show that it changes
  453.             local tempVariation = math.random(-50, 50) / 10  -- Random variation of ±5
  454.             monitor.write(string.format("%.2f MK", plasmaTemp / 1000000 + tempVariation/100))
  455.         end
  456.        
  457.         -- 4. Injection rate (if available, with slight variation)
  458.         if injectionRate then
  459.             line = 14
  460.             monitor.setCursorPos(5, line)
  461.             monitor.setTextColor(colors.white)
  462.             monitor.write("Inj. Rate:")
  463.             monitor.setCursorPos(20, line)
  464.             monitor.setTextColor(colors.yellow)
  465.             local injVariation = math.random(-5, 5)  -- Random variation of ±5
  466.             monitor.write(string.format("%d mB/t", injectionRate + injVariation))
  467.         end
  468.        
  469.         -- 5. Fuel (if available, with simulated consumption)
  470.         if fuel then
  471.             line = 15
  472.             monitor.setCursorPos(5, line)
  473.             monitor.setTextColor(colors.white)
  474.             monitor.write("Fuel:")
  475.             monitor.setCursorPos(20, line)
  476.             monitor.setTextColor(colors.yellow)
  477.             monitor.write(string.format("%d mB", fuel))
  478.         end
  479.     else
  480.         if ignition_in_progress then
  481.             -- Information box during ignition with improved animation
  482.             drawBox(3, 8, screen_width - 3, 15, colors.black, colors.cyan)
  483.             drawTitle("IGNITION SEQUENCE", 3, screen_width - 3, 8, colors.white)
  484.            
  485.             -- More elaborate "Loading" animation with progress bars
  486.             local progress_chars = {"[=      ]", "[==     ]", "[===    ]", "[====   ]",
  487.                                    "[=====  ]", "[====== ]", "[=======]", "[======= ]",
  488.                                    "[=====  ]", "[====   ]", "[===    ]", "[==     ]",
  489.                                    "[=      ]", "[       ]"}
  490.             local char = progress_chars[animation_frame % #progress_chars + 1]
  491.            
  492.             -- Status line with animation icon
  493.             monitor.setCursorPos(5, 10)
  494.             monitor.setTextColor(colors.yellow)
  495.             monitor.write("Reactor ignition in progress")
  496.            
  497.             -- Animation on separate line
  498.             monitor.setCursorPos(15, 11)
  499.             monitor.write(char)
  500.            
  501.             monitor.setCursorPos(5, 13)
  502.             monitor.setTextColor(colors.white)
  503.             monitor.write("Please wait...")
  504.         else
  505.             -- Clear any previous UI elements in this area
  506.             for y = 8, 16 do
  507.                 monitor.setCursorPos(3, y)
  508.                 monitor.setBackgroundColor(colors.black)
  509.                 for x = 3, screen_width - 3 do
  510.                     monitor.write(" ")
  511.                 end
  512.             end
  513.            
  514.             -- Draw proper button centered on screen
  515.             local button_color = colors.blue
  516.             if animation_frame % 8 > 5 then
  517.                 button_color = colors.lightBlue  -- Subtle flashing animation
  518.             end
  519.            
  520.             -- Draw frame around button
  521.             drawBox(button_x1 - 1, button_y1 - 1, button_x2 + 1, button_y2 + 1, colors.black, colors.gray)
  522.            
  523.             -- Fill button with color
  524.             for y = button_y1, button_y2 do
  525.                 monitor.setCursorPos(button_x1, y)
  526.                 monitor.setBackgroundColor(button_color)
  527.                 for x = button_x1, button_x2 do
  528.                     monitor.write(" ")
  529.                 end
  530.             end
  531.            
  532.             -- Button text
  533.             local button_text = "START REACTOR"
  534.             monitor.setTextColor(colors.white)
  535.             monitor.setCursorPos(button_x1 + math.floor((button_x2 - button_x1 - #button_text) / 2), button_y1 + 1)
  536.             monitor.write(button_text)
  537.            
  538.             -- Reset background color
  539.             monitor.setBackgroundColor(colors.black)
  540.         end
  541.     end
  542.    
  543.     -- Footer
  544.     monitor.setTextColor(colors.lightGray)
  545.     monitor.setCursorPos(3, screen_height - 1)
  546.     monitor.write("Fusion Reactor Controler by Le_Jiww")
  547.    
  548.     -- Reset default colors
  549.     monitor.setBackgroundColor(colors.black)
  550.     monitor.setTextColor(colors.white)
  551.    
  552.     last_ignited = ignited
  553. end
  554.  
  555. -- Function to handle button click
  556. local function checkTouch()
  557.     while true do
  558.         local event, side, x, y = os.pullEvent("monitor_touch")
  559.        
  560.         -- Check if we're in the right state to start the reactor
  561.         if not reactor.isIgnited() and not ignition_in_progress then
  562.             -- Improved button hit detection with better margins
  563.             if x >= button_x1 - 1 and x <= button_x2 + 1 and y >= button_y1 - 1 and y <= button_y2 + 1 then
  564.                 -- Set "ignition in progress" state
  565.                 ignition_in_progress = true
  566.                
  567.                 -- Log to console for debugging
  568.                 print("Button pressed - starting reactor ignition sequence")
  569.                
  570.                 -- Visual effect for the click - change button color to cyan
  571.                 for y_pos = button_y1, button_y2 do
  572.                     monitor.setCursorPos(button_x1, y_pos)
  573.                     monitor.setBackgroundColor(colors.cyan)
  574.                     for x_pos = button_x1, button_x2 do
  575.                         monitor.write(" ")
  576.                     end
  577.                 end
  578.                
  579.                 -- Button text
  580.                 local button_text = "STARTING..."
  581.                 monitor.setTextColor(colors.white)
  582.                 monitor.setCursorPos(button_x1 + math.floor((button_x2 - button_x1 - #button_text) / 2), button_y1 + 1)
  583.                 monitor.write(button_text)
  584.                
  585.                 sleep(0.2)  -- Brief pause for visual effect
  586.                
  587.                 -- Send redstone pulse on the chosen face
  588.                 redstone.setOutput(ignitSide, true)
  589.                 sleep(ignitPulseTime)
  590.                 redstone.setOutput(ignitSide, false)
  591.                
  592.                 -- Update display to show ignition sequence
  593.                 displayInfo()
  594.             end
  595.         end
  596.     end
  597. end
  598.  
  599. -- Information on console about how to restart
  600. print(timestamp() .. "Monitor interface initialized")
  601. print(timestamp() .. "Reactor startup configured to send redstone signal to: " .. ignitSide .. " face")
  602. print(timestamp() .. "Reactor stop signals configured for: " .. alarm_side .. " and " .. alarm_side2 .. " faces")
  603. print(timestamp() .. "Touch the START REACTOR button on monitor to activate the reactor")
  604. print(timestamp() .. "Running main loop...")
  605.  
  606. -- Continuous update loop
  607. parallel.waitForAny(
  608.     function()
  609.         while true do
  610.             displayInfo()
  611.             sleep(0.25)  -- Reduce delay for smoother animation
  612.         end
  613.     end,
  614.     checkTouch
  615. )
Advertisement
Add Comment
Please, Sign In to add comment