Squirrel/Server/Functions/Checkpoints/Colour

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Example 1. Returning)
Line 1: Line 1:
__NOTOC__
+
{{Squirrel/Title|Checkpoint.Colour}}
 
This ''Checkpoint'' class member returns or sets the colour of the checkpoint.
 
This ''Checkpoint'' class member returns or sets the colour of the checkpoint.
  
Line 9: Line 9:
 
== Arguments ==
 
== Arguments ==
  
* '''col''' - This is the pointer to a pre-defined colour object.
+
* '''col''' - This is the pointer to a pre-defined RGB colour object.
  
 
== Example 1. Returning ==
 
== Example 1. Returning ==
 +
 +
This example will message the player with the current RGB colour of the checkpoint.
  
 
<code lang="squirrel">
 
<code lang="squirrel">
function onPlayerFootCheckpointHit( player, checkpoint )
+
function onPlayerEnterCheckpoint( player, checkpoint )
 
{
 
{
MessagePlayer( "The current RGB colour of this checkpoint is: " + checkpoint.Colour, player )
+
    local col = checkpoint.Colour;
 +
    MessagePlayer( format( "The current RGB colour of this checkpoint is: %i, %i, %i", col.r, col.g, col.b ), player )
 +
   
 +
    return 1;
 
}
 
}
 
</code>
 
</code>
Line 22: Line 27:
 
=== Notes ===
 
=== Notes ===
  
This example will message the player with the current RBG colour of the checkpoint.
+
The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and event [[Squirrel/Server/Events/Marker/onPlayerEnterCheckpoint|onPlayerEnterCheckpoint]] were used in in this example. More info about them in the corresponding pages.
  
 
== Example 2. Setting ==
 
== Example 2. Setting ==
 +
 +
This example will turn the checkpoint red when a player enters it.
  
 
<code lang="squirrel">
 
<code lang="squirrel">
function onPlayerFootCheckpointHit( player, checkpoint )
+
function onPlayerEnterCheckpoint( player, checkpoint )
 
{
 
{
local COL_RED = Colour( 255, 0, 0 );
+
    checkpoint.Colour = Colour( 255, 0, 0 );
checkpoint.Colour = COL_RED
+
   
 +
    return 1;
 
}
 
}
 
</code>
 
</code>
Line 36: Line 44:
 
=== Notes ===
 
=== Notes ===
  
This example will turn the checkpoint red when a player enters it whilst on foot.
+
The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and event [[Squirrel/Server/Events/Marker/onPlayerEnterCheckpoint|onPlayerEnterCheckpoint]] were used in in this example. More info about them in the corresponding pages.
  
 
== Related Functions ==
 
== Related Functions ==
  
 
{{Squirrel/Server/Functions/Checkpoints}}
 
{{Squirrel/Server/Functions/Checkpoints}}

Revision as of 19:43, 24 September 2010

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

This Checkpoint class member returns or sets the colour of the checkpoint.

Syntax

You can either return or set a new value using this member:

  1. Colour Checkpoint.Colour
  1. Checkpoint.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 checkpoint.

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

Notes

The function MessagePlayer and event onPlayerEnterCheckpoint were used in in this example. More info about them in the corresponding pages.

Example 2. Setting

This example will turn the checkpoint red when a player enters it.

  1.  
  2. function onPlayerEnterCheckpoint( player, checkpoint )
  3. {
  4. checkpoint.Colour = Colour( 255, 0, 0 );
  5. return 1;
  6. }
  7.  

Notes

The function MessagePlayer and event onPlayerEnterCheckpoint were used in in this example. More info about them in the corresponding pages.

Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox