Skip to content

getElementPosition

Type: Shared

Pair: setElementPosition

This function allows you to retrieve the position coordinates of an element. This can be any real world element, including:

This example will print the player position to chat using /pos command.

getElementPosition-1.lua
function whatsMyPosition()
-- get the position of local player
local fX, fY, fZ = getElementPosition(localPlayer);
-- output it to chat
outputChatBox("My current position is X: "..fX.." Y: "..fY.." Z: "..fZ);
end
addCommandHandler("pos", whatsMyPosition);