Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- reactor_control.lua
- -- 1. Wrap the reactor peripheral
- local SIDE = "back" -- or whatever side/name your reactor is connected on
- local reactor = peripheral.wrap(SIDE)
- if not reactor then
- print("Error: No reactor found on side '" .. SIDE .. "'")
- return
- end
- -- 2. Main loop
- while true do
- -- Retrieve energy data
- local energyStored = reactor.getEnergyStored() -- Current energy in the internal buffer
- local maxEnergy = reactor.getEnergyCapacity() or 10000000 -- hypothetical max; adjust if the API differs
- local energyPercent = (energyStored / maxEnergy) * 100
- -- Retrieve some optional data (depends on the mod’s API)
- local isActive = reactor.getActive()
- local fuelAmount = reactor.getFuelAmount() -- total ingots or mB of fuel
- local fuelTemp = reactor.getFuelTemperature() -- in degrees (if available)
- local casingTemp = reactor.getCasingTemperature() -- in degrees (if available)
- -- Simple logic: if energy is almost full, turn reactor off; if low, turn it on
- if energyPercent > 90 then
- reactor.setActive(false)
- elseif energyPercent < 30 then
- reactor.setActive(true)
- end
- -- Clear the screen and print data
- term.clear()
- term.setCursorPos(1,1)
- print("=== Bigger Reactor Control ===")
- print(string.format("Reactor status: %s", isActive and "ON" or "OFF"))
- print(string.format("Energy: %.2f%% (%d / %d)", energyPercent, energyStored, maxEnergy))
- print(string.format("Fuel Amount: %d", fuelAmount or 0))
- if fuelTemp then
- print(string.format("Fuel Temp: %.2f C", fuelTemp))
- end
- if casingTemp then
- print(string.format("Casing Temp: %.2f C", casingTemp))
- end
- -- Wait 5 seconds before checking again
- sleep(5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement