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

Toggle output using only one program

Started by zeldafan99, 22 April 2012 - 04:17 PM
zeldafan99 #1
Posted 22 April 2012 - 06:17 PM
ok, sorry if this is an awfully noob question but, how would i make it so that if i say "lights", for example, and the lights are on, they turn off, and vice versa, instead of having two separate programs. im using bundled cable output btw.
zeldafan99 #2
Posted 22 April 2012 - 06:22 PM
also, i have another question, how come when i use

c = colors.combine( c, colors.red)
rs.setBundledOutput("back", c )

for example, upon restarting the computer or the server i need to use the program TWICE before it outputs?
EmTeaKay #3
Posted 22 April 2012 - 06:33 PM
Use this! Free of charge. And don't feel bad about it being a "noob" question, it took me some time to fine tune it.

while true do
shell.run("clear")
print("Would you like to turn on these lights?")
input = read()
yes = "Yes"
no = "No"
to = "Turn off"
if input == (yes) then
print("Well alrighty!")
redstone.setOutput("back", true )
end

if input == (to) then
print("Turning off!")
redstone.setOutput("back", false )
sleep(3)
end
end
Type 'On' turn it on. Type 'Turn off' to turn off.

I just realized, this is for normal redstone, not bundled. Oops. But you can still use this, just edit it to your needs.
zeldafan99 #4
Posted 22 April 2012 - 06:48 PM
ok, that helps, but can someone please answer my second question? its really annoying every time the server stops, that i have to type things into the console twice for them to work, is there something other then the color api i can use to set bundled cable outputs to false specifically? or am i doing something wrong.
EmTeaKay #5
Posted 22 April 2012 - 07:16 PM
I have no clue, I'm sorry. But as long as your happy using just normal redstone or red alloy cable, then you should be able to use my program.
Luanub #6
Posted 22 April 2012 - 10:21 PM
Try putting this at the top of your code to eliminate the need for the 2nd.


c = colors.combine( c )

Not sure why its needed, but seems to work.
Cloudy #7
Posted 23 April 2012 - 01:32 AM
It should be c = rs.getBundledOutput(side)

Then the combine should work first time - if it doesn't it is something in your code.