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

Need help with Bunled Cable to toggle

Started by Gladox114, 01 June 2017 - 04:13 PM
Gladox114 #1
Posted 01 June 2017 - 06:13 PM
I want to toggle on each color the output and it doesnt work. Can any one help me with this?
Im new at Computercraft and Lua

Here I want to toggle only the Red Cable

right = rs.getBundledInput("right",colors.red)
if right == false then
rs.setBundledOutput("right",colors.combine(rs.getBundledInput("right"),colors.red))
else
rs.setBundledOutput("right",colors.subtract(rs.getBundledInput("right"),colors.red))
end
Bomb Bloke #2
Posted 02 June 2017 - 12:39 AM
local curOutput = rs.getBundledOutput( "right" )

if colours.test( curOutput, colours.red ) then
	rs.setBundledOutput( "right", colours.subtract( curOutput, colours.red ) )
else
	rs.setBundledOutput( "right", colours.combine( curOutput, colours.red ) )
end