Squirrel/Server/Functions/Spheres/Colour
From Liberty Unleashed Wiki
(Difference between revisions)
(→Arguments) |
(→Example 1. Returning) |
||
Line 12: | Line 12: | ||
== Example 1. Returning == | == Example 1. Returning == | ||
+ | |||
+ | This example will message the player with the current RGB colour of the sphere. | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
function onPlayerFootSphereHit( player, sphere ) | function onPlayerFootSphereHit( player, sphere ) | ||
{ | { | ||
− | + | local col = sphere.Colour; | |
+ | MessagePlayer( format( "The current RGB colour of this sphere is: %i, %i, %i", col.r, col.g, col.b ), player ); | ||
+ | |||
+ | return 1; | ||
} | } | ||
</code> | </code> | ||
− | |||
− | |||
=== Notes === | === Notes === | ||
− | The | + | The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and event [[Squirrel/Server/Events/Player/onPlayerFootSphereHit|onPlayerFootSphereHit]] were used in this example. More info about them in the corresponding pages. |
== Example 2. Setting == | == Example 2. Setting == |
Revision as of 23:53, 8 November 2010
This Sphere class member returns or sets the colour ID of the sphere.
Syntax
You can either return or set a new value using this member:
Colour Sphere.Colour
Sphere.Colour = Colour col
Arguments
- col - This is the pointer to a pre-defined RGB colour object.
Example 1. Returning
This example will message the player with the current RGB colour of the sphere.
function onPlayerFootSphereHit( player, sphere ) { local col = sphere.Colour; MessagePlayer( format( "The current RGB colour of this sphere is: %i, %i, %i", col.r, col.g, col.b ), player ); return 1; }
Notes
The function MessagePlayer and event onPlayerFootSphereHit were used in this example. More info about them in the corresponding pages.
Example 2. Setting
function onPlayerFootSphereHit( player, sphere ) { sphere.Colour = 1; }
This will set the sphere to colour 1 when it is hit.
Notes
The call onPlayerFootSphereHit was used in in this example. More info about this in the corresponding page.