Object.Pos

From Liberty Unleashed Wiki
Jump to: navigation, search
Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events


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

Syntax

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

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

Arguments

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

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.

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).

Notes

The function FindObject and eventonPlayerCommand was used in in this example. More info about this in the corresponding page.

Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox