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

What is the colors api for?

Started by Jummit, 05 October 2017 - 06:27 AM
Jummit #1
Posted 05 October 2017 - 08:27 AM
Yes, there are some useful things in this API, but the functions seems very strange to me. For what would you use colors.combine()? It creates a set of colors. And how am i supposed to use this? I could also create a table with colors, and instead of using colors.test, i could look in the table for the color…
SquidDev #2
Posted 05 October 2017 - 08:42 AM
From the wiki:
This is useful in conjunction with Bundled Cables from the RedPower mod, RedNet Cables from the MineFactory Reloaded mod
The redstone API's bundled cable methods accept a bitmask of which colours should be on or off. So rs.setBundledOutput("left", colours.combine(colours.white, colours.orange)) will turn on the white and orange parts of a bundled cable.
Jummit #3
Posted 05 October 2017 - 08:45 AM
Ok, so this is not for color manipulation, only for bundled cables.
You cant do colors.combine(colors.red, colors.white) and get colors.orange.
Edited on 05 October 2017 - 06:45 AM
Anavrins #4
Posted 05 October 2017 - 12:10 PM
When you convert the value of colors.red or colors.orange, into binary, you get a 16-bit number, this binary array basically acts as a way to tell which colored cables should be active when you give that number to setBundledOutput.
00…000001 means only white cable
00…000010 means only orange cable
00…000011 means both white and orange cable

colors.combine justs simplifies the action of combining 0001 and 0010 into 0011, without the need to do it with logical operators.

More info: http://www.computerc...iki/Colors_(API)
Edited on 05 October 2017 - 10:13 AM