Scripting/Squirrel/Functions/cRGB: Difference between revisions
Jump to navigation
Jump to search
This wiki is using an old backup from 2020
Some information may be old/missing
(w) |
ProsuWANTED (talk | contribs) (Uppercase fix & better example.) |
||
Line 1: | Line 1: | ||
Creates an instance and returns the pointer. | |||
== Syntax == | == Syntax == | ||
<pre>RGB( | <pre>RGB( r, g, b )</pre> | ||
== Arguments == | == Arguments == | ||
* ''int'' ''' | * ''int'' '''r''' - Red | ||
* ''int'' ''' | * ''int'' '''g''' - Green | ||
* ''int'' ''' | * ''int'' '''b''' - Blue | ||
== Example == | == Example == | ||
<source> | |||
function | <source lang="squirrel"> | ||
function onPlayerCommand( player, cmd, text ) | |||
{ | { | ||
MessagePlayer(" | if( cmd == "red" ) | ||
{ | |||
MessagePlayer("You're now red!", player); | |||
player.Color = Color(255, 0, 0); | |||
} | |||
else if ( cmd == "green" ) | |||
{ | |||
MessagePlayer("You're now green!", player); | |||
player.Color = Color(0, 255, 0); | |||
} | |||
else if ( cmd == "blue" ) | |||
{ | |||
MessagePlayer("You're now blue!", player); | |||
player.Color = Color(0, 0, 255); | |||
} | |||
} | } | ||
</source> | </source> | ||
=== Notes === | === Notes === | ||
Call [[onPlayerCommand]] was used in this example. More info in the page. | |||
== Related Functions == | == Related Functions == | ||
{{Scripting/Squirrel/Functions/Data Structures}} | {{Scripting/Squirrel/Functions/Data Structures}} |
Revision as of 16:40, 2 July 2015
Creates an instance and returns the pointer.
Syntax
RGB( r, g, b )
Arguments
- int r - Red
- int g - Green
- int b - Blue
Example
function onPlayerCommand( player, cmd, text )
{
if( cmd == "red" )
{
MessagePlayer("You're now red!", player);
player.Color = Color(255, 0, 0);
}
else if ( cmd == "green" )
{
MessagePlayer("You're now green!", player);
player.Color = Color(0, 255, 0);
}
else if ( cmd == "blue" )
{
MessagePlayer("You're now blue!", player);
player.Color = Color(0, 0, 255);
}
}
Notes
Call onPlayerCommand was used in this example. More info in the page.