Squirrel/Server/Functions/Spheres/Colour

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(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 = 1;
+
sphere.Colour = Colour( 255, 0, 0 );
 
}
 
}
 
</code>
 
</code>
 
This will set the sphere to colour 1 when it is hit.
 
  
 
=== Notes ===
 
=== Notes ===

Latest revision as of 23:54, 8 November 2010

Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events

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:

  1. Colour Sphere.Colour
  1. 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.

  1.  
  2. function onPlayerFootSphereHit( player, sphere )
  3. {
  4. local col = sphere.Colour;
  5. MessagePlayer( format( "The current RGB colour of this sphere is: %i, %i, %i", col.r, col.g, col.b ), player );
  6. return 1;
  7. }
  8.  

[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.

  1.  
  2. function onPlayerFootSphereHit( player, sphere )
  3. {
  4. sphere.Colour = Colour( 255, 0, 0 );
  5. }
  6.  

[edit] Notes

The call onPlayerFootSphereHit was used in in this example. More info about this in the corresponding page.

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox