Difference between revisions of "Colors.test"

From ComputerCraft Wiki
Jump to: navigation, search
m (added a link)
m (Int -> {{type|number}})
 
(4 intermediate revisions by 2 users not shown)
Line 2: Line 2:
 
{{Function
 
{{Function
 
|name=colors.test
 
|name=colors.test
|args=[[int (type)|int]] colors, [[int (type)|int]] color
+
|args={{Type|number}} colors, {{Type|number}} color
|api=color
+
|api=colors
|returns=[[boolean]] whether or not all elements of <var>color</var> are contained in the set <var>colors</var>
+
|returns={{Type|boolean}} whether or not all elements of <var>color</var> are contained in the set <var>colors</var>
 
|addon=ComputerCraft
 
|addon=ComputerCraft
 
|desc=Tests whether <var>color</var> is contained within <var>colors</var>; <var>color</var> may be a single color or may be a set of colors (in the latter case, <code>true</code> is returned only if <em>all</em> colors in <var>color</var> are contained in <var>colors</var>)
 
|desc=Tests whether <var>color</var> is contained within <var>colors</var>; <var>color</var> may be a single color or may be a set of colors (in the latter case, <code>true</code> is returned only if <em>all</em> colors in <var>color</var> are contained in <var>colors</var>)
Line 14: Line 14:
 
}}
 
}}
 
}}
 
}}
 +
 +
[[Category:API_Functions]]

Latest revision as of 00:47, 12 July 2013


Grid Redstone.png  Function colors.test
Tests whether color is contained within colors; color may be a single color or may be a set of colors (in the latter case, true is returned only if all colors in color are contained in colors)
Syntax colors.test(number colors, number color)
Returns boolean whether or not all elements of color are contained in the set colors
Part of ComputerCraft
API colors

Examples

Grid paper.png  Example
Combine white, magenta, and light blue, then check if light blue is within the set
Code
print(colors.test(colors.combine(colors.white, colors.magenta, colours.lightBlue), colors.lightBlue))
Output true