Squirrel/Server/Functions/Spheres/Pos

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
 
Line 3: Line 3:
  
 
== 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 Sphere.Pos</code>
 
<code>Vector Sphere.Pos</code>
Line 10: Line 11:
  
 
* '''vPos''' - This is the position of the sphere as a vector
 
* '''vPos''' - This is the position of the sphere as a vector
 +
 
== Example 1. Returning ==
 
== Example 1. Returning ==
 +
 +
This example will return the position of the sphere when the player hits it.
  
 
<code lang="squirrel">
 
<code lang="squirrel">
function onPlayerFootSphereHit( player, sphere )
+
function onPlayerEnterSphere( player, sphere )
 
{
 
{
MessagePlayer( "The current position of this sphere is: " + sphere.Pos, player )
+
    MessagePlayer( "The current position of this sphere is: " + sphere.Pos, player );
 +
   
 +
    return 1;
 
}
 
}
 
</code>
 
</code>
  
This example will return the position of the sphere when the player hits it.
+
=== Notes ===
 +
 
 +
The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and callback [[Squirrel/Server/Events/Sphere/onPlayerEnterSphere|onPlayerEnterSphere]] were used in this example. More info about them can be found in the corresponding pages.
  
 
== Example 2. Setting ==
 
== Example 2. Setting ==
  
 
<code lang="squirrel">
 
<code lang="squirrel">
function onPlayerFootSphereHit( player, sphere )
+
function onPlayerEnterSphere( player, sphere )
 
{
 
{
sphere.Pos = Vector( player.Pos.x + 2, player.Pos.y, player.Pos.z );
+
    local pos = player.Pos;
 +
    sphere.Pos = Vector( pos.x + 2.0, pos.y, pos.z );
 +
   
 +
    return 1;
 
}
 
}
 
</code>
 
</code>
Line 34: Line 45:
 
=== Notes ===
 
=== Notes ===
  
The call [[Squirrel/Server/Events/Player/onPlayerFootSphereHit|onPlayerFootSphereHit]] was used in in this example. More info about this in the corresponding page.
+
The callback [[Squirrel/Server/Events/Sphere/onPlayerEnterSphere|onPlayerEnterSphere]] was used in this example. More info about it can be found in the corresponding page.
  
 
== Related Functions ==
 
== Related Functions ==
  
 
{{Squirrel/Server/Functions/Spheres}}
 
{{Squirrel/Server/Functions/Spheres}}

Latest revision as of 14:44, 13 March 2011

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

This Sphere class member returns or sets the position of the given sphere.

[edit] Syntax

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

  1. Vector Sphere.Pos
  1. Sphere.Pos = Vector vPos

[edit] Arguments

  • vPos - This is the position of the sphere as a vector

[edit] Example 1. Returning

This example will return the position of the sphere when the player hits it.

  1.  
  2. function onPlayerEnterSphere( player, sphere )
  3. {
  4. MessagePlayer( "The current position of this sphere is: " + sphere.Pos, player );
  5. return 1;
  6. }
  7.  

[edit] Notes

The function MessagePlayer and callback onPlayerEnterSphere were used in this example. More info about them can be found in the corresponding pages.

[edit] Example 2. Setting

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

This example will set the position of the sphere to be 2 x co-ordinates away from the player that hit it.

[edit] Notes

The callback onPlayerEnterSphere was used in this example. More info about it can be found in the corresponding page.

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox