Squirrel/Server/Functions/Spheres/Pos
From Liberty Unleashed Wiki
(Difference between revisions)
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 | + | function onPlayerEnterSphere( player, sphere ) |
{ | { | ||
− | + | MessagePlayer( "The current position of this sphere is: " + sphere.Pos, player ); | |
+ | |||
+ | return 1; | ||
} | } | ||
</code> | </code> | ||
− | + | === 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 | + | function onPlayerEnterSphere( player, sphere ) |
{ | { | ||
− | + | 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 | + | 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
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:
Vector Sphere.Pos
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.
function onPlayerEnterSphere( player, sphere ) { MessagePlayer( "The current position of this sphere is: " + sphere.Pos, player ); return 1; }
[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
function onPlayerEnterSphere( player, sphere ) { local pos = player.Pos; sphere.Pos = Vector( pos.x + 2.0, pos.y, pos.z ); return 1; }
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.