This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Xixili's profile picture

bundledcable input/output (V1.58)

Started by Xixili, 23 July 2014 - 11:59 PM
Xixili #1
Posted 24 July 2014 - 01:59 AM
Hello everyone,

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
Bomb Bloke #2
Posted 24 July 2014 - 02:15 AM
Instead of:

rs.setBundledOutput("bottom", colours.black)

Use:

rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), colours.black))

Check out the commands in the colors API.
Edited on 24 July 2014 - 12:17 AM
Xixili #3
Posted 24 July 2014 - 02:23 AM
Instead of:

rs.setBundledOutput("bottom", colours.black)

Use:

rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), colours.black))

Check out the commands in the colors API.

Maybe I dont understand this but when using that line it still turns off the other reactors.
Bomb Bloke #4
Posted 24 July 2014 - 02:43 AM
In that case, you may need to look where the black wire is leading to.
Xixili #5
Posted 24 July 2014 - 02:47 AM
In that case, you may need to look where the black wire is leading to.
The black wire goes nowhere.
Im using it to turn off the reactor that I want to turn off.
But I dont want the other reactors go off if they are on and thats what happening now.
Bomb Bloke #6
Posted 24 July 2014 - 02:51 AM
This may be a silly question, but do you understand what the line I gave you does?
Xixili #7
Posted 24 July 2014 - 02:54 AM
This may be a silly question, but do you understand what the line I gave you does?
Yes I just found out.
I fixed it now and it works smoothly now.

Thank you


   if rs.testBundledInput("bottom", colors.yellow) then
rs.setBundledOutput("bottom", colors.subtract(rs.getBundledOutput("bottom"), colours.yellow))
	term.setCursorPos(11, 9)
term.setTextColor(colors.white)
term.setBackgroundColor(colors.gray)
term.write("	 Futo Maki Reactor 4	 ")
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.combine(rs.getBundledOut put("bottom"), colours.yellow))
	term.setCursorPos(11, 9)
term.setTextColor(colors.white)
term.setBackgroundColor(colors.gray)
term.write("	 Futo Maki Reactor 4	 ")
term.setCursorPos(11,10)
term.setTextColor(colors.lime)
term.setBackgroundColor(colors.gray)
term.write("		GOING ONLINE		 ")
sleep(3)
   shell.run("mainframe")
   end
end
Edited on 24 July 2014 - 12:55 AM