Squirrel/Server/Functions/Spheres/Colour
From Liberty Unleashed Wiki
(Difference between revisions)
(→Example 1. Returning) |
(→Example 2. Setting) |
||
Line 30: | Line 30: | ||
== Example 2. Setting == | == Example 2. Setting == | ||
+ | |||
+ | This example will turn the sphere red when a player enters it. | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
function onPlayerFootSphereHit( player, sphere ) | function onPlayerFootSphereHit( player, sphere ) | ||
{ | { | ||
− | sphere.Colour = | + | sphere.Colour = Colour( 255, 0, 0 ); |
} | } | ||
</code> | </code> | ||
− | |||
− | |||
=== Notes === | === Notes === |
Latest revision as of 23:54, 8 November 2010
This Sphere class member returns or sets the colour ID of the sphere.
[edit] Syntax
You can either return or set a new value using this member:
Colour Sphere.Colour
Sphere.Colour = Colour col
[edit] Arguments
- col - This is the pointer to a pre-defined RGB colour object.
[edit] 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; }
[edit] Notes
The function MessagePlayer and event onPlayerFootSphereHit were used in this example. More info about them in the corresponding pages.
[edit] Example 2. Setting
This example will turn the sphere red when a player enters it.
function onPlayerFootSphereHit( player, sphere ) { sphere.Colour = Colour( 255, 0, 0 ); }
[edit] Notes
The call onPlayerFootSphereHit was used in in this example. More info about this in the corresponding page.