Squirrel/Server/Functions/Checkpoints/Pos

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Example 2. Setting)
Line 1: Line 1:
__NOTOC__
+
{{Squirrel/Title|Checkpoint.Pos}}
 
This ''Checkpoint'' class member returns or sets the position of the given checkpoint.
 
This ''Checkpoint'' class member returns or sets the position of the given checkpoint.
  
 
== Syntax ==
 
== Syntax ==
 +
 
You can either return or set a new value using this member:
 
You can either return or set a new value using this member:
 
<code>Vector Checkpoint.Pos</code>
 
<code>Vector Checkpoint.Pos</code>
Line 12: Line 13:
  
 
== Example 1. Returning ==
 
== Example 1. Returning ==
 +
 +
This example will message the player with the current position of the checkpoint.
  
 
<code lang="squirrel">
 
<code lang="squirrel">
function onPlayerFootCheckpointHit( player, checkpoint )
+
function onPlayerEnterCheckpoint( player, checkpoint )
 
{
 
{
MessagePlayer( "The current Position of this checkpoint is: " + checkpoint.Pos, player )
+
    local pos = checkpoint.Pos;
 +
    MessagePlayer( format( "The current position of this checkpoint is: %.2f, %.2f, %.2f", pos.x, pos.y, pos.z ), player );
 +
   
 +
    return 1;
 
}
 
}
 
</code>
 
</code>
Line 22: Line 28:
 
=== Notes ===
 
=== Notes ===
  
This example will message the player with the current position 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 move the checkpoint 2 x coordinates away from the player when they enter the checkpoint.
  
 
<code lang="squirrel">
 
<code lang="squirrel">
function onPlayerFootCheckpointHit( player, checkpoint )
+
function onPlayerEnterCheckpoint( player, checkpoint )
 
{
 
{
checkpoint.Pos = Vector( player.Pos.x + 2, player.Pos.y, player.Pos.z );
+
    local pos = player.Pos;
 +
    checkpoint.Pos = Vector( pos.x + 2, pos.y, pos.z );
 +
   
 +
    return 1;
 
}
 
}
 
</code>
 
</code>
Line 35: Line 46:
 
=== Notes ===
 
=== Notes ===
  
This example will move the checkpoint 2 x coordinates away from the player when they enter the checkpoint.
+
The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and event [[Squirrel/Server/Events/Marker/onPlayerEnterCheckpoint|onPlayerEnterCheckpoint]] were used 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:54, 24 September 2010

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

This Checkpoint class member returns or sets the position of the given checkpoint.

Syntax

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

  1. Vector Checkpoint.Pos
  1. Checkpoint.Pos = Vector vPos

Arguments

  • vPos - This is the position of the checkpoint as a vector.

Example 1. Returning

This example will message the player with the current position of the checkpoint.

  1.  
  2. function onPlayerEnterCheckpoint( player, checkpoint )
  3. {
  4. local pos = checkpoint.Pos;
  5. MessagePlayer( format( "The current position of this checkpoint is: %.2f, %.2f, %.2f", pos.x, pos.y, pos.z ), 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 move the checkpoint 2 x coordinates away from the player when they enter the checkpoint.

  1.  
  2. function onPlayerEnterCheckpoint( player, checkpoint )
  3. {
  4. local pos = player.Pos;
  5. checkpoint.Pos = Vector( pos.x + 2, pos.y, pos.z );
  6. return 1;
  7. }
  8.  

Notes

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

Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox