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

Ugh... strange problem (related to redstone)

Started by zeldafan99, 18 April 2012 - 10:59 PM
zeldafan99 #1
Posted 19 April 2012 - 12:59 AM
ok so, im trying to make it so a program opens a door, then another program closes it, its been working for the past ever, but i accidentaly broke the computer and re-did the code AND NOW ITS NOT,


i have:

"open"

rs.setBundledoutput("back", colors.red, true)

and the other program is "close"

rs.setBundledoutput("back", colors.red, false)


yet if i do any of these programs it sends a true signal though red.. and cant be turned off untill i stop the computer..
Luanub #2
Posted 19 April 2012 - 01:08 AM
its best to use the colors API in conjunction with the redstone API


To Turn on:
c = colors.combine( c, colors.red)
rs.setBundledOutput("back", c )

To Turn Off:
c = colors.subtract( c, colors.red)
rs.setBundledOutput("back", c )

There are other ways to achieve this but I believe this is the cleanest.
Cloudy #3
Posted 19 April 2012 - 01:09 AM
Well you wrote the code wrong when redoing it :)/>/> This:
rs.setBundledOutput("back", 0)
is what your close program should look like.

Edit: Damn ninjas! Yes, the above code would work - albeit with a little alteration:

To Turn on:
c = rs.getBundledOutput("back")
c = colors.combine( c, colors.red)
rs.setBundledOutput("back", c )

To Turn Off:
c = rs.getBundledOutput("back")
c = colors.subtract( c, colors.red)
rs.setBundledOutput("back", c )
The alteration is so this would work properly - otherwise c will be nil when it is first being used. You will also maintain the current output of the RedPower bundled cable, and only alter the red sub wire.
MysticT #4
Posted 19 April 2012 - 01:10 AM
The rs.setBundledOutput() function takes only 2 parameters: the side and the colors to set. To turn off every output you have to do:

rs.setBundledOutput("side", 0) -- 0 is no colors

Edit: ninja'd :)/>/>, just by 2 minutes :)/>/>
zeldafan99 #5
Posted 19 April 2012 - 01:14 AM
The rs.setBundledOutput() function takes only 2 parameters: the side and the colors to set. To turn off every output you have to do:

rs.setBundledOutput("side", 0) -- 0 is no colors

Edit: ninja'd :)/>/>, just by 2 minutes :)/>/>

if it takes only 2 paramiters,how do i set it to turn of a specific color?
Luanub #6
Posted 19 April 2012 - 01:20 AM
The rs.setBundledOutput() function takes only 2 parameters: the side and the colors to set. To turn off every output you have to do:

rs.setBundledOutput("side", 0) -- 0 is no colors

Edit: ninja'd :)/>/>, just by 2 minutes :)/>/>

if it takes only 2 paramiters,how do i set it to turn of a specific color?
Using the colors API.

use colors.combine to add a color to turn on and colors.subtract to remove the color you want to turn off. Small example above. You can also do multiples like

c = colors.combine(c, colors.red, colors.blue, etc)
zeldafan99 #7
Posted 19 April 2012 - 01:34 AM
ok i got it. thanks guys! real help, quick responce by multiple people.. saved me some trouble.