Skip to content

GetObjectPosition

The GetObjectPosition function retrieves the position of a specified object in the game world. The position is typically represented by the X, Y, and Z coordinates, which indicate the object's location in the 3D space of the game.

Parameters

  • object: The object identifier (GUID) or unit identifier (such as "player", "target", "focus", etc.) for which to retrieve the position.

Returns

  • x: The X coordinate of the specified object.
  • y: The Y coordinate of the specified object.
  • z: The Z coordinate of the specified object.

Example Usage in Lua

Here is an example of how to use the GetObjectPosition function in Lua:

local api = ...

-- Function to print the position of the player
function PrintPlayerPosition()
    local player = "player"
    local x, y, z = api.GetObjectPosition(player)
    print("Player Position - X: " .. x .. ", Y: " .. y .. ", Z: " .. z)
end

-- Function to print the position of the target
function PrintTargetPosition()
    local target = "target"
    local x, y, z = api.GetObjectPosition(target)
    print("Target Position - X: " .. x .. ", Y: " .. y .. ", Z: " .. z)
end

-- Function to print the position of the focus
function PrintFocusPosition()
    local focus = "focus"
    local x, y, z = api.GetObjectPosition(focus)
    print("Focus Position - X: " .. x .. ", Y: " .. y .. ", Z: " .. z)
end

-- Call the functions
PrintPlayerPosition()
PrintTargetPosition()
PrintFocusPosition()