Object.Pos
From Liberty Unleashed Wiki
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:
Vector object.Pos
object.Pos = Vector vPos
Arguments
- vPos - This is the new position for the object as a Vector
Example 1. Returning
function onPlayerCommand( player, cmd, text ) { if ( cmd == "objectpos" ) { local obj = FindObject( 0 ); if ( obj ) MessagePlayer( "Object 0s position is: " + obj.Pos, player ); else MessagePlayer( "Object 0 does not exist", player ); } }
This command will tell the player the co-ordinates of object id 0.
Example 2. Setting
function onPlayerCommand( player, cmd, text ) { if ( cmd == "setobjectpos" ) { local newpos = Vector( 100.00, 90.00, 1.00 ); local obj = FindObject( 0 ); if ( obj ) obj.Pos = newpos; } }
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.