Appel
addon.Platform:GetUnitPointFragmentObservation(unit, powerType, kind)
Disponible directement via addon ; aucune dépendance n'est nécessaire.
Ce qu'elle fait
Observe une ressource à points que le client rapporte en fragments (les Braises enflammées de Mists of Pandaria). La valeur actuelle utilise exactement UnitPower(unit,powerType,true) et le maximum UnitPowerMax(unit,powerType,true) ; le résultat est divisé par MAX_POWER_PER_EMBER de Blizzard (10), donc 35 fragments valent 3,5. Politique de sondage uniquement. Les données manquantes, en échec, restreintes ou mal formées restent indisponibles ; aucun repli sur la requête en unités entières n'a jamais lieu. Aucun cache n'est ajouté.
Arguments
| Nom | Type | Ce qu'elle fait |
|---|---|---|
self | RMPlatform | Adaptateur de plateforme Rotation Master (implicite avec un appel par deux-points). |
unit | string | Identifiant d'unité exact et non vide, transmis tel quel. |
powerType | number | Sélecteur de ressource explicite, lisible, fini et entier non négatif. |
kind | string | Exactement la valeur actuelle pour UnitPower ou le maximum pour UnitPowerMax. |
Retours
| 1 | number | nil | Quantité finie en unités entières, avec sa partie fractionnaire ; nil si indisponible. |
|---|---|---|
| 2 | string | nil | Motif de politique, de validation de la requête ou de disponibilité d'une observation requise pour une quantité nil. |
Éditions
Les fonctions utilitaires intégrées sont enregistrées sur toutes les éditions. Ce qui diffère, c'est l'API du jeu qu'elles lisent ; quand l'une manque, la fonction utilitaire se rabat sur une alternative ou renvoie nil avec une raison.
- Indisponible sur cette édition (la raison figure dans l'infobulle)
- Uniquement tant que les solutions de repli de Blizzard pour les fonctions obsolètes sont actives
| API du jeu | |||||
|---|---|---|---|---|---|
UnitPower | |||||
UnitPowerMax | |||||
canaccessvalue |
Valeurs secrètes (Retail et Forever)
Sur Retail et Forever, le jeu transmet aux addons des valeurs secrètes. Cette fonction utilitaire vérifie ce qu'elle lit (addon.Platform:CanReadValue) et renvoie nil avec une raison telle que restricted-value au lieu d'une valeur secrète qu'elle ne peut pas comparer. Traitez nil comme indisponible, pas comme false.
Exemple
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.5Dépendances
pointFragmentsPerWhole(builtin:Platform/points.lua:pointFragmentsPerWhole)
Source
Platform/points.lua, ligne 162. En lecture seule dans le jeu ; Dupliquer crée une copie modifiable.
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




