Software works as intended for me, you should have it set to startup just in case the server restarts or something and you find a lovely crater where your reactor used to be…
The second version is currently untested…
Right now it takes two redstone inputs to work out the reactor temperature state (cold, warm, or hot), and gives two outputs (one toggles the reactor, another is a bundled wire output for whatever you want).
It now also accepts an optional input from an MFE/MFSU(should be the first of a chain of storage units with the redstone output set to emit if partially filled) to work out if the reactor ran out of cells or the storage is full.
The second version uses a single bundled cable for all input/output, if you do not want to use an optional in/out then set it to 0 (the reactor will think it is empty if you disable the storage state signal, but this has no adverse effects).
Protip: You can set the storage state input to be a lever, which will basically act as a manual override shutoff switch. You could also do this with an OR gate, so the reactor continues to monitor the EU storage.
The input and output sides are freely change-able from the top of the code, as well as the three colours it uses within bundled cables for the outputs. The two temperature inputs are hooked up by using Thermal Monitors on the reactor, preferably with the cold heat level being lower than the hot.
The second version only has one side for all wiring, but the side is still configurable.
Here's the code:
Spoiler
os.pullEvent = os.pullEventRaw
local coolDownSide = "left"
local heatUpSide = "right"
local controlSide = "front"
local displaySide = "top"
local storageStateSide = "bottom"
local onCol = colors.white
local offCol = colors.black
local emptyCol = colors.blue
local storageFullCol = colors.red
local reactorEnabled = true
local reactorEmpty = false
local storageFull = false
local timeSinceActive = 0
local timeSinceFull = 0
local timeSinceNotFull = 0
local width, height = term.getSize()
local companyName = "HexCorp Industries"
local function clearScreen()
term.clear()
term.setCursorPos(1, 1)
term.write("Nuclear Reactor Control Unit")
term.setCursorPos(width-#companyName+1, height)
term.write(companyName)
end
local function doTick()
timeSinceActive = timeSinceActive + 1
local hot = rs.getInput(heatUpSide)
local cold = rs.getInput(coolDownSide)
local full = rs.getInput(storageStateSide)
if full then
timeSinceFull = timeSinceFull + 1
timeSinceNotFull = 0
else
timeSinceNotFull = timeSinceNotFull + 1
timeSinceFull = 0
storageFull = false
end
if timeSinceFull >= 20 then
hot = true
timeSinceFull = 20
storageFull = true
else storageFull = false end
if timeSinceNotFull >= 20 then
timeSinceNotFull = 20
reactorEmpty = true
else reactorEmpty = false end
if reactorEnabled then
if hot then
reactorEnabled = false
reactorEmpty = false
end
else
reactorEmpty = false
if not cold then
reactorEnabled = true
timeSinceActive = 0
end
end
clearScreen()
term.setCursorPos(1, 3)
term.write("Current status: ")
if reactorEmpty then
term.write("Cells Depleted")
rs.setOutput(controlSide, false)
rs.setBundledOutput(displaySide, emptyCol + onCol)
elseif storageFull then
term.write("Energy Storage Full")
rs.setOutput(controlSide, true)
rs.setBundledOutput(displaySide, storageFullCol + offCol)
elseif reactorEnabled then
term.write("Active")
rs.setOutput(controlSide, false)
rs.setBundledOutput(displaySide, onCol)
else
term.write("Inactive")
rs.setOutput(controlSide, true)
rs.setBundledOutput(displaySide, offCol)
end
sleep(0.25)
end
while true do doTick() end
Here's some better commented code that only uses one bundled cable (untested):
Spoiler
--[[START OF CONFIG]]--
--[[POSSIBLE CABLE COLOURS]]--
--white orange magneta lightBlue
--yellow lime pink gray
--lightGray cyan purple blue
--brown green red black
--[[BUNDLED CABLE SIDE]]--
local cableSide = "back" --side of computer the bundled cable is on
--[[REQUIRED CABLES]]--
local coolDownCol = colors.white --input from heat sensor (temp should be lower than heatUp one)
local heatUpCol = colors.red --input from heat sensor (temp should be higher than coolDown one)
local controlCol = colors.black --output to control the reactor
--[[OPTIONAL CABLES]]--
local storageStateCol = colors.green --input from EU storage set to "Emit if partially full"
local onCol = colors.pink --output to show the reactor is online
local offCol = colors.purple --output to show the reactor is offline
local emptyCol = colors.lime --output to show the reactor needs uranium [requires storageStateCol]
local storageFullCol = colors.orange --output to show the EU storage is full [requires storageStateCol]
--[[OTHER SETTINGS]]--
local companyName = "HexCorp Industries" --name of your company
--[[END OF CONFIG]]--
os.pullEvent = os.pullEventRaw --Prevent Ctrl+T from closing the program
--Initialise reactor state variables
local reactorEnabled = true
local reactorEmpty = false
local storageFull = false
local timeSinceActive = 0
local timeSinceFull = 0
local timeSinceNotFull = 0
local width, height = term.getSize() --Store the size of the screen
local function clearScreen()
term.clear() --Clear the screen
--Print the program and company names
term.setCursorPos(1, 1)
term.write("Nuclear Reactor Control Unit")
term.setCursorPos(width-#companyName+1, height)
term.write(companyName)
end
local function doTick()
--Increment reactor active timer and check inputs
timeSinceActive = timeSinceActive + 1
local hot = rs.testBundledInput(cableSide, heatUpCol)
local cold = rs.testBundledInput(cableSide, coolDownCol)
local full = rs.testBundledInput(cableSide, storageStateCol)
if full then --The EU storage is giving a signal, increment its variable
timeSinceFull = timeSinceFull + 1
timeSinceNotFull = 0
else --The EU storage is not giving a signal, increment its other variable
timeSinceNotFull = timeSinceNotFull + 1
timeSinceFull = 0
storageFull = false
end
if timeSinceFull >= 20 then --There has been an EU signal for 20 ticks, the EU storage may be full
hot = true
timeSinceFull = 20
storageFull = true
else storageFull = false end
if timeSinceNotFull >= 20 then --There has not been an EU signal for 20 ticks, the reactor may be out of uranium
timeSinceNotFull = 20
reactorEmpty = true
else reactorEmpty = false end
if reactorEnabled then
if hot then --Disable the reactor, because it is too hot
reactorEnabled = false
reactorEmpty = false
end
else
reactorEmpty = false
if not cold then --Enable the reactor, because it has cooled down
reactorEnabled = true
timeSinceActive = 0
end
end
clearScreen()
term.setCursorPos(1, 3)
term.write("Current status: ")
if reactorEmpty then
term.write("Cells Depleted")
rs.setBundledOutput(cableSide, emptyCol + onCol)
elseif storageFull then
term.write("Energy Storage Full")
rs.setBundledOutput(cableSide, storageFullCol + offCol + controlCol)
elseif reactorEnabled then
term.write("Active")
rs.setBundledOutput(cableSide, onCol)
else
term.write("Inactive")
rs.setBundledOutput(cableSide, offCol + controlCol)
end
term.setCursorPos(1, 4)
term.write("Temperature: ")
if hot then term.write("|Cold |Warm >Hot")
elseif cold then term.write("|Cold >Warm |Hot")
else term.write(">Cold |Warm |Hot") end
sleep(0.25) --Four ticks to the second
end
while true do doTick() end
Here's a couple of images showing my setup (they're a bit big, also only first software version):
Spoiler
Feel free to change it as you see fit or make suggestions as to improving it, but I suggest you use this as a startup file as computers tend to do a fresh reboot on a server restart (from what I've noticed). If you do use this in a project, mentioning me would be nice, thought I don't enforce it…just don't say you made it! :)/>/>
Also, if you're a bit confused, here's a world I made (flatmap/creative) showing how to set up the reactor with the newer software version:
https://dl.dropbox.c...r%20Control.zip