Reference › Function reference › Platform

Platform.player_movement.GetPlayerMovementObservation

public

Call as

addon.Platform:GetPlayerMovementObservation()

Available directly through addon; no dependency is needed.

What it does

Observe the player current movement speed on supported readable clients. This queries GetUnitSpeed for player only, without testing another unit or redirecting vehicle ownership. Zero means stationary; positive finite fractional speeds remain valid. Missing, failed, restricted or malformed observations return nil with a reason.

Arguments

NameTypeWhat it does
selfRMPlatformRotation Master platform adapter (implicit with colon calls).

Returns

1table | nilFresh readable record with finite nonnegative speed, or nil when unavailable.
2string | nilPolicy or availability reason for a nil movement observation.

Editions

Built In helpers are registered on every edition. What differs is the game API they read; where one is missing the helper falls back or returns nil with a reason.

  • Not available on that edition (the reason is in the tooltip)
  • Only while Blizzard's deprecation fallbacks are on
Game APIClassic EraTBC AnniversaryClassic progressionForeverRetail
GetUnitSpeedClassic EraTBC AnniversaryClassic progressionForeverRetail
canaccessvalueClassic EraTBC AnniversaryClassic progressionForeverRetail

Secret values (Retail and Forever)

On Retail and Forever the game hands addons secret values. This helper checks what it reads (addon.Platform:CanReadValue) and returns nil with a reason such as restricted-value instead of a secret it cannot compare. Treat nil as unavailable, not as false.

Example

local movement = addon.Platform:GetPlayerMovementObservation()
if not movement then return nil end
return movement.speed > 0

Source

Platform/player_movement.lua, line 15. Read only in game; Duplicate makes an editable copy.

Platform.player_movement.GetPlayerMovementObservation(self)
    local policy=self:GetCombatDataPolicy()
    if policy~='probe' and policy~='restricted' then return nil,'unsupported-policy' end
    if type(GetUnitSpeed)~='function' then return nil,'missing-api' end
    local ok,speed=pcall(GetUnitSpeed,'player')
    if not ok then return nil,'api-error' end
    if not self:CanReadValue(speed) then return nil,'restricted-value' end
    if canaccessvalue and not canaccessvalue(speed) then return nil,'restricted-value' end
    if speed==nil then return nil,'movement-data-unavailable' end
    if type(speed)~='number' or speed~=speed or speed==math.huge or speed==-math.huge or speed<0 then return nil,'invalid-api-result' end
    return {speed=speed}

Back to Function reference