Jump to content




How do I turn off one color in a bundled cable?


  • You cannot reply to this topic
5 replies to this topic

#1 MoRBiiD Legacy

  • Members
  • 13 posts

Posted 10 April 2015 - 12:11 AM

is there a way to turn off only one cable?

#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 10 April 2015 - 12:22 AM

View PostGAMR DUD3, on 10 April 2015 - 12:11 AM, said:

is there a way to turn off only one cable?

Set the output to the cables you want to remain on, eg.

rs.setBundledOutput( 2^2 + 2^8 )
--#now turn off one
rs.setBundledOutput( 2^2 )


#3 MoRBiiD Legacy

  • Members
  • 13 posts

Posted 10 April 2015 - 12:38 AM

View PostKingofGamesYami, on 10 April 2015 - 12:22 AM, said:

View PostGAMR DUD3, on 10 April 2015 - 12:11 AM, said:

is there a way to turn off only one cable?

Set the output to the cables you want to remain on, eg.

rs.setBundledOutput( 2^2 + 2^8 )
--#now turn off one
rs.setBundledOutput( 2^2 )

how about when you want all lights to be managed independently? (for example: turn on red, turn on blue, turn off blue, turn on red. not turn on red, turn on blue (deactivates red), turn off blue) this is what happens when i use my code:
  • shell.run("clear")
  • textutils.slowPrint("Welcome to *******'s light system!")
  • textutils.slowPrint("")
  • textutils.slowPrint("Red--Blue")
  • textutils.slowWrite("Color: ")
  • input = read()
  • if (input) == ("red") then
  • redstone.testBundledInput("back", colors.red)
  • if (redstone.testBundledInput("back", colors.red)) == false then
  • textutils.slowPrint("Status: Off")
  • textutils.slowWrite("Turn on?: ")
  • input = read()
  • if (input) == ("yes") then
  • redstone.setBundledOutput("back", colors.red)
  • sleep(1)
  • shell.run("a")
  • else shell.run("a")
  • end
  • elseif (redstone.testBundledInput("back", colors.red)) == true then
  • textutils.slowPrint("Status: On")
  • textutils.slowWrite("Turn off?: ")
  • input = read()
  • if (input) == ("yes") then
  • redstone.setBundledOutput("back", 0)
  • sleep(1)
  • shell.run("a")
  • end
  • end
  • elseif (input) == ("blue") then
  • redstone.testBundledInput("back", colors.blue)
  • if (redstone.testBundledInput("back", colors.blue)) == false then
  • textutils.slowPrint("Status: Off")
  • textutils.slowWrite("Turn on?: ")
  • input = read()
  • if (input) == ("yes") then
  • redstone.setBundledOutput("back", colors.blue)
  • sleep(1)
  • shell.run("a")
  • else shell.run("a")
  • end
  • elseif (redstone.testBundledInput("back", colors.blue)) == true then
  • textutils.slowPrint("Status: On")
  • textutils.slowWrite("Turn off?: ")
  • input = read()
  • if (input) == ("yes") then
  • redstone.setBundledOutput("back", 0)
  • sleep(1)
  • shell.run("a")
  • else shell.run("a")
  • end
  • end
  • else textutils.slowPrint("Sorry, not an option.")
  • sleep(2)
  • shell.run("a")
  • end


#4 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 10 April 2015 - 01:29 AM

rs.setBundledOutput( "back", rs.getBundledOutput( "back" ) - *your color here* )

Removes 1 color.

#5 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 10 April 2015 - 07:59 AM

... though that's a bit risky if the line might be executed when the colour is already disabled. Hence colours.subtract(), which can handle such a scenario correctly:

rs.setBundledOutput( "back", colours.subtract(rs.getBundledOutput( "back" ), *your color here* ))


#6 The Lone Wolfling

  • Members
  • 43 posts

Posted 10 April 2015 - 02:41 PM

View PostBomb Bloke, on 10 April 2015 - 07:59 AM, said:

... though that's a bit risky if the line might be executed when the colour is already disabled. Hence colours.subtract(), which can handle such a scenario correctly:

rs.setBundledOutput( "back", colours.subtract(rs.getBundledOutput( "back" ), *your color here* ))
I have two functions to do basically this - add or subtract (a set of) color(s). I find it a whole lot more intuitive to use.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users