Jump to content




What is the colors api for?


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

#1 Jummit

  • Members
  • 306 posts
  • LocationJulfander Squad Studio

Posted 05 October 2017 - 07: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...

#2 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 05 October 2017 - 07:42 AM

From the wiki:

Quote

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.

#3 Jummit

  • Members
  • 306 posts
  • LocationJulfander Squad Studio

Posted 05 October 2017 - 07: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 by Jummit, 05 October 2017 - 07:45 AM.


#4 Anavrins

  • Members
  • 775 posts

Posted 05 October 2017 - 11:10 AM

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 by Anavrins, 05 October 2017 - 11:13 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users