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

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

Started by MoRBiiD Legacy, 09 April 2015 - 11:11 PM
MoRBiiD Legacy #1
Posted 10 April 2015 - 01:11 AM
is there a way to turn off only one cable?
KingofGamesYami #2
Posted 10 April 2015 - 01:22 AM
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 )
MoRBiiD Legacy #3
Posted 10 April 2015 - 01:38 AM
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:
  1. shell.run("clear")
  2. textutils.slowPrint("Welcome to *******'s light system!")
  3. textutils.slowPrint("")
  4. textutils.slowPrint("Red–Blue")
  5. textutils.slowWrite("Color: ")
  6. input = read()
  7. if (input) == ("red") then
  8. redstone.testBundledInput("back", colors.red)
  9. if (redstone.testBundledInput("back", colors.red)) == false then
  10. textutils.slowPrint("Status: Off")
  11. textutils.slowWrite("Turn on?: ")
  12. input = read()
  13. if (input) == ("yes") then
  14. redstone.setBundledOutput("back", colors.red)
  15. sleep(1)
  16. shell.run("a")
  17. else shell.run("a")
  18. end
  19. elseif (redstone.testBundledInput("back", colors.red)) == true then
  20. textutils.slowPrint("Status: On")
  21. textutils.slowWrite("Turn off?: ")
  22. input = read()
  23. if (input) == ("yes") then
  24. redstone.setBundledOutput("back", 0)
  25. sleep(1)
  26. shell.run("a")
  27. end
  28. end
  29. elseif (input) == ("blue") then
  30. redstone.testBundledInput("back", colors.blue)
  31. if (redstone.testBundledInput("back", colors.blue)) == false then
  32. textutils.slowPrint("Status: Off")
  33. textutils.slowWrite("Turn on?: ")
  34. input = read()
  35. if (input) == ("yes") then
  36. redstone.setBundledOutput("back", colors.blue)
  37. sleep(1)
  38. shell.run("a")
  39. else shell.run("a")
  40. end
  41. elseif (redstone.testBundledInput("back", colors.blue)) == true then
  42. textutils.slowPrint("Status: On")
  43. textutils.slowWrite("Turn off?: ")
  44. input = read()
  45. if (input) == ("yes") then
  46. redstone.setBundledOutput("back", 0)
  47. sleep(1)
  48. shell.run("a")
  49. else shell.run("a")
  50. end
  51. end
  52. else textutils.slowPrint("Sorry, not an option.")
  53. sleep(2)
  54. shell.run("a")
  55. end
KingofGamesYami #4
Posted 10 April 2015 - 02:29 AM

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

Removes 1 color.
Bomb Bloke #5
Posted 10 April 2015 - 08: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* ))
The Lone Wolfling #6
Posted 10 April 2015 - 03:41 PM
… 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.