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

Regarding Bundled Cables

Started by flaminsnowman99, 13 July 2012 - 03:47 PM
flaminsnowman99 #1
Posted 13 July 2012 - 05:47 PM
Hey, I'm working on making a nuclear reactor setup thats hooked into a computer which runs all of the programs. I have a menu and subMenu system set up. When the reactor is started, one of the colored wires is turned on. What I wanted to know was if I choose a different thing from the menu, will that color wire turn off? And when it goes back to the home menu after a selection is chosen, will all those wires stay on? I will paste the code so you can see what I mean.

local function reactorMenu()
while true do
  term.clear()
  term.setCursorPos(1,1)
  print("***************************")
  print()
print("Reactor Menu")
  print()
  print("1. Start Reactor")
  print("2. Stop Reactor")
  print("3. Perform Maintainence")
  print("4. Start Refill Timer")
  print("5. Back")
  e, p = os.pullEvent()
  if e == "char" then
   if p == "1" then
    term.clear()
    term.setCursorPos(1,1)
    textutils.slowPrint("Loading Mainframes...")
    sleep(3)
    print()
    textutils.slowPrint("Loading Subsystems...")
    sleep(2)
    redstone.setOutput("bottom", colors.brown)
    sleep(2)
    print()
    textutils.slowPrint("Starting Cooling Systems...")
    sleep(2)
    print()
    textutils.slowPrint("Starting Reactor...")
    sleep(2)
    redstone.setBundledOutput("bottom", colors.green)
    sleep(2)
    print()
    textutils.slowPrint("Reactor Successfully Started")
   elseif p == "2" then
    term.clear()
    term.setCursorPos(1,1)
    textutils.slowPrint("Shutting Down Mainframes...")
    sleep(3)
    print()
    textUtils.slowPrint("Shutting Down Subsystems...")
    sleep(2)
    print()
    textutils.slowPrint("Closing Water Cooling Valve...")
    sleep(2)
    print()
    textutils.slowPrint("Shutting Down Reactor...")
    sleep(2)
    print()
    textutils.slowPrint("Reactor Successfully Shutdown")
    sleep(2)
    return
   elseif p == "3" then
    term.clear()
    term.setCursorPos(1,1)
    textutils.slowPrint("Checking Reactor is Shutdown...")
    sleep(2)
    textutils.slowPrint("Reactor Shutdown...")
    sleep(1)
    textutils.slowPrint("Shutting Water Cooling Valve...")
    sleep(2)
    print()
    textutils.slowPrint("Opening Maintainence Doors")
    sleep(2)
    redstone.setBundledOutput("bottom", colors.cyan)
    sleep(2)
    return
   elseif p == "4" then
    term.clear()
    term.setCursorPos(1,1)
    textutils.slowPrint("Function Not Implemented...")
    sleep(2)
    return
   elseif p = "5" then
    retrun
   end
  end
end
end
So, let me explain what all of this does. Brown wires turn on the water. Green turn the reactor on, and Cyan opens some of the doors in the place. So when the reactor is started, the green wires will turn on and start the reactor. What i wanna know is in the stop reactor part of the code. Do I need to have some code to turn the wires off? I know to turn wires on it redstone.setBundledOutput("side", colors.green) but is there something i need to do to turn it off?

Also another question I have is how do I get only certain lines of the code to appear on the monitor next to the computer?
Thanks for the help!
OmegaVest #2
Posted 13 July 2012 - 07:12 PM
For the monitor: Wrap the monitor. Literally mon=peripheral.wrap(side). Then use mon. in place of term. for those commands. You can tell it to display whatever text you want, really.

For bundled cables: First, just using the color name won't turn on that wire while leaving the others in tact. Actually, it will turn off those wires. Instead of calling just that color, make sure you add this set of lines.

bOut = 0

--Code
--When updating to add a color:

bOut = colors.add(bOut, COLOR)
rs.setBundledOutput("bottom", bOut)

--When subtracting a color (turning that wire off)

bOut = colors.subtract(bOut, COLOR)
rs.setBundledOutput("bottom", bOut)


And, personally, I would have the computer run a whole line of ifs before using setBundledOutput, since it can turn multiple wires on and/or off at once. So, say you wanted to close all doors, and turn the water on (Emergency Lockdown mode), then you would have

bOut = colors.add(bOut, colors.brown)
bOut = colors.subtract(bOut, colors.cyan)
bOut = colors.subract(bOut, colors.green)
rs.setBundledOutput("bottom", bOut)




Now, some questions because you have not included your setup in the post.
1) Did you put a not gate at the end of the green wire? If not, and it is hooked straight to the reactor, it will turn off when you turn the green wire on.
2) Why do you use slowprint? Are you trying to be dramatic?
3) How are you controlling the water? Is it a RP pump system? BC pumps? Or are you letting it flow down overtop and have a bucket/retriever or piston system?
flaminsnowman99 #3
Posted 13 July 2012 - 07:38 PM
Now, some questions because you have not included your setup in the post.
1) Did you put a not gate at the end of the green wire? If not, and it is hooked straight to the reactor, it will turn off when you turn the green wire on.
2) Why do you use slowprint? Are you trying to be dramatic?
3) How are you controlling the water? Is it a RP pump system? BC pumps? Or are you letting it flow down overtop and have a bucket/retriever or piston system?
Thank you so much. This is extremely helpful. Let me answer the other questions you have.
1) Yes, there is a NOT-Gate that hooks into the reactor.
2) I just like slowprint. :)/>/>
3) The water is being controlled by pistons.
MysticT #4
Posted 13 July 2012 - 07:46 PM
Just a little correction:

bOut = colors.add(bOut, COLOR)
should be:

bOut = colors.combine(bOut, COLOR)
OmegaVest #5
Posted 13 July 2012 - 10:08 PM
Aaaaaaaand there's Mystic, once again fixing my mistakes. I often feel like he looks at my posts and quietly shakes his head.

Ah kay. I wondered about the water more than anything, because I've used an RP2 pump system, and that was. . . well, I had fun doing it. It adds a sense of actually doing something with the water. The biggest problem it has is it needs blutricity.
And, I guess you could use buildcraft pumps if you had, say, additional buidlcraft objects. Valve pipes. Though, that's really just the same thing as a piston system. Again, just makes it look and feel like the plant is actively trying to cool itself. And there's always room for failure with that one. 3.x gates + no traversing water = EMERGENCY LOCKDOWN!!! :P/>/>
MysticT #6
Posted 13 July 2012 - 10:31 PM
Aaaaaaaand there's Mystic, once again fixing my mistakes. I often feel like he looks at my posts and quietly shakes his head.
:P/>/>
Just wanted to avoid future post saying "There's an error on line N that says …, pleas fix it now!!!" or something like that :)/>/>
ParanoidPlayer1 #7
Posted 13 July 2012 - 10:32 PM
Also another question I have is how do I get only certain lines of the code to appear on the monitor next to the computer?
For the monitor deal, you can wrap the mon (like OmegaVest said) using mon = peripheral.wrap(side). Then you can simply use mon.write("bla bla bla") to write and all the term. commands

For my turtle program i use:
(second part clears the mon and the computer)

monLeft = peripheral.wrap("left")


term.clear()
monLeft.clear()
term.setCursorPos( 1, 1 )
monLeft.setCursorPos( 1, 1 )

Only issue i find with that is that you cannot use the print command, so i figured out you can assign the output to devices.
From my code:

term.redirect(monLeft)
print ("Testing monitor feed... ")
term.restore()
print ("Testing computer feed... ")

i like this because i do not have to run a program via "monitor left <programname>"

kinda long, but i like being complete and explaining stuff. :P/>/>