Im creating a script to control my 4 nuclear reactors.
I dont run into any errors but I cant turn more then 1 reactor online.
For example:
I turn Reactor 1 online, it goes online.
When I want reactor 2 online together with 1, it turns Reactor 2 online and 1 offline.
This also counts for all the 4 reactors.
When turning another reactor online it turns the one before offline.
I think the problem is in
if rs.testBundledInput("bottom", colors.white) then
rs.setBundledOutput("bottom", colours.black)
Each reactor has his own cable color of course.
Im using the black color to tell the reactor to go offline if online.
But it also does for all the other reactors.
Is there a way to avoid this?
Im running Computercraft 1.58
os.pullEvent = os.pullEventRaw
local width, height = term.getSize()
-- ######################
-- #### GUI
-- ######################
while true do
term.setCursorPos(1, 1)
term.setBackgroundColor(colors.lightBlue)
term.clear()
term.setTextColor(colors.black)
term.setBackgroundColor(colors.orange)
term.clearLine()
term.setCursorPos(1, height)
term.clearLine()
local text = "Nuclear Research Facility"
term.setCursorPos(math.floor((width - #text) / 2), 1)
term.write(text)
-- ######################
-- #### Reactor 1
-- ######################
term.setTextColor(colors.white)
term.setBackgroundColor(colors.gray)
term.setCursorPos(1, 2)
term.write(" ")
term.setCursorPos(1, 3)
term.write(" ")
if rs.testBundledInput("bottom", colors.white) then
rs.setBundledOutput("bottom", colours.black)
term.setCursorPos(11, 9)
term.setTextColor(colors.white)
term.setBackgroundColor(colors.gray)
term.write(" Futo Maki Reactor 1 ")
term.setCursorPos(11,10)
term.setTextColor(colors.red)
term.setBackgroundColor(colors.gray)
term.write(" GOING OFFLINE ")
rs.setBundledOutput("bottom", colours.black)
sleep(3)
shell.run("mainframe")
else
rs.setBundledOutput("bottom", colors.white)
term.setCursorPos(11, 9)
term.setTextColor(colors.white)
term.setBackgroundColor(colors.gray)
term.write(" Futo Maki Reactor 1 ")
term.setCursorPos(11,10)
term.setTextColor(colors.lime)
term.setBackgroundColor(colors.gray)
term.write(" GOING ONLINE ")
sleep(3)
shell.run("mainframe")
end
end