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

[Question][Lua]Restone Bundled cables

Started by exploder, 18 September 2012 - 11:55 AM
exploder #1
Posted 18 September 2012 - 01:55 PM
Hi everyone.

How can I turn off one color at once, because rs.setBundledOutput("bottom",0) turns all outputs off, so how could I just turn off only one color at a time.

Another thing is if one color is on and I turn the other color on then the first color is not being outputted anymore and the second color turn on.




function light()
if redstone.testBundledInput("bottom",2) == false then
term.setCursorPos(1,13)
print("			 +---------------------+")
print("			 :Lights are turning on:")
print("			 +---------------------+")
sleep(0.5)
rs.setBundledOutput("bottom",2)
term.clear()
elseif redstone.testBundledInput("bottom",2) == true then
term.setCursorPos(1,13)
print("			+----------------------+")
print("			:Lights are turning off:")
print("			+----------------------+")
sleep(0.5)
term.clear()
rs.setBundledOutput("bottom",0)
end
end

function windows()
if redstone.testBundledInput("bottom",1) == true then
term.setCursorPos(1,13)
print("			+----------------------+")
print("			:  Windows are opening :")
print("			+----------------------+")
sleep(0.5)
rs.setBundledOutput("bottom",0)
term.clear()
elseif redstone.testBundledInput("bottom",1) == false then
term.setCursorPos(1,13)
print("			+----------------------+")
print("			:  Windows are closing :")
print("			+----------------------+")
sleep(0.5)
rs.setBundledOutput("bottom",1)
term.clear()
end
end

Sorry for bad description, because I couldn't figure it out how to explain it to other people, and English is not my native language.
KaoS #2
Posted 18 September 2012 - 02:04 PM
well what you do is get the current output and take away the colour you don't want


local function addcol(col, side)
  rs.setBundledOutput(side, colors.combine(rs.getBundledOutput(side),col))
end
local function remcol(col, side)
  rs.setBundledOutput(side, colors.subtract(rs.getBundledOutput(side),col))
end
remcol removes the colour from the specified side
addcol does the opposite

example of use:

remcol(colors.black, 'back')
exploder #3
Posted 18 September 2012 - 05:35 PM
well what you do is get the current output and take away the colour you don't want


local function addcol(col, side)
  rs.setBundledOutput(side, colors.combine(rs.getBundledOutput(side),col))
end
local function remcol(col, side)
  rs.setBundledOutput(side, colors.subtract(rs.getBundledOutput(side),col))
end
remcol removes the colour from the specified side
addcol does the opposite

example of use:

remcol(colors.black, 'back')

KaoS thank you for replying.

Yes, these things worked, thank you very much.