API/colors: Difference between revisions
Jump to navigation
Jump to search
imported>OCDoc Import Imported from legacy OpenComputers documentation at ocdoc.cil.li |
Clean up Markdown artifacts from DokuWiki migration |
||
| Line 1: | Line 1: | ||
= Colors API = | = Colors API = | ||
This "API" serves a global table that allows you to refer to colors by their name, instead of their associated ID/number. The table serves as a look-up in both directions, so for example | This "API" serves a global table that allows you to refer to colors by their name, instead of their associated ID/number. The table serves as a look-up in both directions, so for example <code>colors.blue</code> has the value <code>11</code>, whereas <code>colors[11]</code> has the string value <code>blue</code>. These are the defined colors: | ||
* White ( | * White (<code>white</code>), Number: 0 - Orange (<code>orange</code>), Number: 1 - Magenta (<code>magenta</code>), Number: 2 - Light Blue (<code>lightblue</code>), Number: 3 - Yellow (<code>yellow</code>), Number: 4 - Lime (<code>lime</code>), Number: 5 - Pink (<code>pink</code>), Number: 6 - Gray (<code>gray</code>), Number: 7 - Silver (<code>silver</code>), Number: 8 - Cyan (<code>cyan</code>), Number: 9 - Purple (<code>purple</code>), Number: 10 - Blue (<code>blue</code>), Number: 11 - Brown (<code>brown</code>), Number: 12 - Green (<code>green</code>), Number: 13 - Red (<code>red</code>), Number: 14 - Black (<code>black</code>), Number: 15 | ||
Note that the indexing starts at zero, not one. | Note that the indexing starts at zero, not one. | ||
Useful for setting or getting bundled redstone output or input, for example: | Useful for setting or getting bundled redstone output or input, for example: <syntaxhighlight lang="lua"> | ||
local component = require("component") local colors = require("colors") local rs = component.redstone rs.setBundledOutput(sides.back, colors.green, rs.getBundledInput(sides.front, colors.blue)) | |||
</syntaxhighlight> would output the back signal strength to the front. | |||
== Contents == | == Contents == | ||
{{:API/contents}} | {{:API/contents}} | ||
Latest revision as of 20:26, 24 August 2026
Colors API
This "API" serves a global table that allows you to refer to colors by their name, instead of their associated ID/number. The table serves as a look-up in both directions, so for example colors.blue has the value 11, whereas colors[11] has the string value blue. These are the defined colors:
- White (
white), Number: 0 - Orange (orange), Number: 1 - Magenta (magenta), Number: 2 - Light Blue (lightblue), Number: 3 - Yellow (yellow), Number: 4 - Lime (lime), Number: 5 - Pink (pink), Number: 6 - Gray (gray), Number: 7 - Silver (silver), Number: 8 - Cyan (cyan), Number: 9 - Purple (purple), Number: 10 - Blue (blue), Number: 11 - Brown (brown), Number: 12 - Green (green), Number: 13 - Red (red), Number: 14 - Black (black), Number: 15
Note that the indexing starts at zero, not one.
Useful for setting or getting bundled redstone output or input, for example:
local component = require("component") local colors = require("colors") local rs = component.redstone rs.setBundledOutput(sides.back, colors.green, rs.getBundledInput(sides.front, colors.blue))would output the back signal strength to the front.
Contents
| APIs | |
|---|---|
| OpenOS | buffer - colors - component - computer - event - filesystem - uuid - internet - keyboard - note - process - rc - robot - serialization - shell - sides - term - text - thread - transforms - unicode |
| Lua Libraries | coroutine - package - io - os |