Llamar como
addon.Platform:GetUnitPointFragmentObservation(unit, powerType, kind)
Disponible directamente a través de addon; no se necesita ninguna dependencia.
Qué hace
Observa un recurso de puntos que el cliente informa en fragmentos (Ascuas ardientes de Mists of Pandaria). Current usa exactamente UnitPower(unit,powerType,true) y maximum, UnitPowerMax(unit,powerType,true); el resultado se divide entre MAX_POWER_PER_EMBER de Blizzard (10), así que 35 fragmentos son 3,5. Solo es una política de sondeo. Los datos que faltan, fallan, están restringidos o mal formados siguen sin estar disponibles; nunca recurre a la consulta de unidades enteras. No se agrega caché.
Argumentos
| Nombre | Tipo | Qué hace |
|---|---|---|
self | RMPlatform | Adaptador de plataforma de Rotation Master (implícito en las llamadas con dos puntos). |
unit | string | Token de unidad exacto y no vacío, que se pasa sin cambios. |
powerType | number | Selector de poder entero no negativo, finito, legible y explícito. |
kind | string | Exactamente current para UnitPower o maximum para UnitPowerMax. |
Retornos
| 1 | number | nil | Cantidad finita en unidades enteras con su parte fraccionaria; nil si no está disponible. |
|---|---|---|
| 2 | string | nil | Motivo de política, validación de la consulta o disponibilidad de una observación necesaria para una cantidad 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 disponible en esa edición (el motivo aparece en la información emergente)
- Solo mientras estén activas las alternativas de Blizzard para API obsoletas
| API del juego | |||||
|---|---|---|---|---|---|
UnitPower | |||||
UnitPowerMax | |||||
canaccessvalue |
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 embers = Enum.PowerType.BurningEmbers
if not embers then return nil end
local current = addon.Platform:GetUnitPointFragmentObservation("player", embers, "current")
if current == nil then return nil end
return current >= 3.5Dependencias
pointFragmentsPerWhole(builtin:Platform/points.lua:pointFragmentsPerWhole)
Código fuente
Platform/points.lua, línea 162. Solo lectura en el juego; Duplicar crea una copia editable.
Platform.points.GetUnitPointFragmentObservation(self, unit, powerType, kind)
if self:GetCombatDataPolicy()~='probe' then return nil,'unsupported-policy' end
if not self:CanReadValue(unit) or not self:CanReadValue(powerType) or not self:CanReadValue(kind) then return nil,'restricted-value' end
if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
if type(powerType)~='number' or powerType~=powerType or powerType<0 or powerType==math.huge or powerType%1~=0 then return nil,'invalid-point-power-query' end
if kind~='current' and kind~='maximum' then return nil,'invalid-point-power-query' end
local api
if kind=='current' then api=UnitPower else api=UnitPowerMax end
if type(api)~='function' then return nil,'missing-api' end
local ok,result=pcall(api,unit,powerType,true)
if not ok then return nil,'api-error' end
if not self:CanReadValue(result) then return nil,'restricted-value' end
if canaccessvalue and not canaccessvalue(result) then return nil,'restricted-value' end
if result==nil then return nil,'point-power-unavailable' end
if type(result)~='number' or result~=result or result==math.huge or result==-math.huge then return nil,'invalid-api-result' end
return result/pointFragmentsPerWhole




