Reference › Function reference › Platform

Platform.range.GetRangeCheckBounds

public

Call as

addon.Platform:GetRangeCheckBounds(unit)

Available directly through addon; no dependency is needed.

What it does

Read the public LibRangeCheck interval for a unit. A successful upper bound is inclusive; a positive failed lower bound is strict. A zero lower floor is synthetic. Neither bound is an exact distance, and a missing upper bound is not proof that the unit is outside every radius. Unavailable, malformed, restricted or failed observations return nil with a reason.

Arguments

NameTypeWhat it does
selfRMPlatformRotation Master platform adapter (implicit with colon calls).
unitstringCurrent unit token whose distance from the player should be observed.

Returns

1table | nilReadable interval with optional minimum and maximum bounds in yards. At least one bound is present; nil when unavailable.
2string | nilAvailability or validation reason for a nil result.

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.

It reads no game API directly.

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 bounds = addon.Platform:GetRangeCheckBounds("target")
if not bounds then return nil end
if bounds.maximum and bounds.maximum <= 8 then return true end
if bounds.minimum and bounds.minimum >= 8 then return false end
return nil -- the interval straddles 8 yards

Source

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

Platform.range.GetRangeCheckBounds(self, unit)
    if not self:CanReadValue(unit) then return nil,'restricted-value' end
    if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
    if not LibStub then return nil,'missing-range-provider' end
    local loaded,provider=pcall(function() return LibStub('LibRangeCheck-3.0',true) end)
    if not loaded or not provider or type(provider.GetRange)~='function' then return nil,'missing-range-provider' end
    local ok,minimum,maximum=pcall(provider.GetRange,provider,unit)
    if not ok then return nil,'range-provider-error' end
    if not self:CanReadValue(minimum) or not self:CanReadValue(maximum) then return nil,'restricted-value' end
    for _,bound in pairs({minimum=minimum,maximum=maximum}) do
        if type(bound)~='number' or bound~=bound or bound<0 or bound==math.huge then return nil,'invalid-range-result' end
    end
    if minimum==nil and maximum==nil then return nil,'range-unavailable' end
    if minimum and maximum and minimum>maximum then return nil,'invalid-range-result' end
    return {minimum=minimum,maximum=maximum}

Back to Function reference