Referencia › Referencia de funciones › Platform

Platform.range.GetRangeCheckBounds

pública

Llamar como

addon.Platform:GetRangeCheckBounds(unit)

Disponible directamente a través de addon; no se necesita ninguna dependencia.

Qué hace

Lee el intervalo público de LibRangeCheck para una unidad. Un límite superior correcto es inclusivo; un límite inferior positivo fallido es estricto. Un mínimo inferior de cero es sintético. Ninguno de los límites es una distancia exacta, y la falta de límite superior no demuestra que la unidad esté fuera de todos los radios. Las observaciones no disponibles, mal formadas, restringidas o fallidas devuelven nil con un motivo.

Argumentos

NombreTipoQué hace
selfRMPlatformAdaptador de plataforma de Rotation Master (implícito en las llamadas con dos puntos).
unitstringToken de la unidad actual cuya distancia al jugador se debe observar.

Retornos

1table | nilIntervalo legible con límites mínimo y máximo opcionales en metros. Al menos un límite está presente; nil si no está disponible.
2string | nilMotivo de disponibilidad o de validación para un resultado nil.

Ediciones

Las funciones auxiliares integradas se registran en todas las ediciones. Lo que cambia es la API del juego que leen; donde falta alguna, la función auxiliar usa una alternativa o devuelve nil con un motivo.

No lee directamente ninguna API del juego.

Valores secretos (Retail y Forever)

En Retail y Forever, el juego les entrega a los addons valores secretos. Esta función auxiliar verifica lo que lee (addon.Platform:CanReadValue) y, en lugar de un secreto que no puede comparar, devuelve nil con un motivo como restricted-value. Trata nil como no disponible, no como falso.

Ejemplo

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

Código fuente

Platform/range.lua, línea 129. Solo lectura en el juego; Duplicar crea una copia editable.

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}

Volver a Referencia de funciones