Squirrel/Server/Functions/Objects/Pos

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with '{{Squirrel/Title|Pickup.Pos}} __NOTOC__ This ''Pickup'' class member returns or sets the position of the given pickup. == Syntax == You can either return or set a new value usin…')
 
 
Line 1: Line 1:
{{Squirrel/Title|Pickup.Pos}}
+
{{Squirrel/Title|Object.Pos}}
 
__NOTOC__
 
__NOTOC__
This ''Pickup'' class member returns or sets the position of the given pickup.
+
This ''Object'' class member returns or sets the position of the given object.
  
 
== 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 pickup.Pos</code>
+
<code>Vector object.Pos</code>
<code>pickup.Pos = Vector vPos</code>
+
<code>object.Pos = Vector vPos</code>
  
 
== Arguments ==
 
== Arguments ==
  
* '''vPos''' - This is the new position for the pickup as a [[Squirrel/Script_Types/Vector|Vector]]
+
* '''vPos''' - This is the new position for the object as a [[Squirrel/Script_Types/Vector|Vector]]
  
 
== Example 1. Returning ==
 
== Example 1. Returning ==
Line 16: Line 16:
 
function onPlayerCommand( player, cmd, text )
 
function onPlayerCommand( player, cmd, text )
 
{
 
{
if ( cmd == "pickuppos" )
+
if ( cmd == "objectpos" )
 
{
 
{
local pickup = FindPickup( 0 );
+
local obj = FindObject( 0 );
if ( pickup ) MessagePlayer( "Pickup 0s position is: " + pickup.Pos, player );
+
if ( obj ) MessagePlayer( "Object 0s position is: " + obj.Pos, player );
else MessagePlayer( "Pickup 0 does not exist", player );
+
else MessagePlayer( "Object 0 does not exist", player );
 
}
 
}
 
}
 
}
 
</code>
 
</code>
  
This command will tell the player the co-ordinates of pickup id 0.
+
This command will tell the player the co-ordinates of object id 0.
  
 
== Example 2. Setting ==
 
== Example 2. Setting ==
Line 32: Line 32:
 
function onPlayerCommand( player, cmd, text )
 
function onPlayerCommand( player, cmd, text )
 
{
 
{
if ( cmd == "setpickuppos" )
+
if ( cmd == "setobjectpos" )
 
{
 
{
 
local newpos = Vector( 100.00, 90.00, 1.00 );
 
local newpos = Vector( 100.00, 90.00, 1.00 );
local pickup = FindPickup( 0 );
+
local obj = FindObject( 0 );
if ( pickup ) pickup.Pos = newpos;
+
if ( obj ) obj.Pos = newpos;
 
}
 
}
 
}
 
}
 
</code>
 
</code>
  
This command will set the pickup with ID 0s position to the co-ordinates of 100.00 (X), 90.00 (Y), 1.00 (Z).
+
This command will set the object with ID 0s position to the co-ordinates of 100.00 (X), 90.00 (Y), 1.00 (Z).
  
 
=== Notes ===
 
=== Notes ===
  
The function [[Squirrel/Server/Functions/Pickups/FindPickup|FindPickup]] and event[[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] was used in in this example. More info about this in the corresponding page.
+
The function [[Squirrel/Server/Functions/Objects/FindObject|FindObject]] and event[[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] was used in in this example. More info about this in the corresponding page.
  
 
== Related Functions ==
 
== Related Functions ==
  
{{Squirrel/Server/Functions/Pickups}}
+
{{Squirrel/Server/Functions/Objects}}

Latest revision as of 11:42, 12 October 2010

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


This Object class member returns or sets the position of the given object.

[edit] Syntax

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

  1. Vector object.Pos
  1. object.Pos = Vector vPos

[edit] Arguments

  • vPos - This is the new position for the object as a Vector

[edit] Example 1. Returning

  1.  
  2. function onPlayerCommand( player, cmd, text )
  3. {
  4. if ( cmd == "objectpos" )
  5. {
  6. local obj = FindObject( 0 );
  7. if ( obj ) MessagePlayer( "Object 0s position is: " + obj.Pos, player );
  8. else MessagePlayer( "Object 0 does not exist", player );
  9. }
  10. }
  11.  

This command will tell the player the co-ordinates of object id 0.

[edit] Example 2. Setting

  1.  
  2. function onPlayerCommand( player, cmd, text )
  3. {
  4. if ( cmd == "setobjectpos" )
  5. {
  6. local newpos = Vector( 100.00, 90.00, 1.00 );
  7. local obj = FindObject( 0 );
  8. if ( obj ) obj.Pos = newpos;
  9. }
  10. }
  11.  

This command will set the object with ID 0s position to the co-ordinates of 100.00 (X), 90.00 (Y), 1.00 (Z).

[edit] Notes

The function FindObject and eventonPlayerCommand 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