Aufruf als
Conditions.spatial_stats.observation(cache, method, unit, power)
Erfassen Sie die Abhängigkeit Conditions.spatial_stats.observation und rufen Sie sie dann unter diesem Namen auf. Ein Aufruf über den Namensraum übergibt kein self: Verwenden Sie einen Doppelpunkt-Aufruf oder übergeben Sie das Objekt selbst.
Was sie bewirkt
Reads one health or mana number for a PROXIMITY_* condition through the evaluation cache, protected against errors. With power set it passes Enum.PowerType.Mana as the second argument; restricted, negative, NaN or infinite readings are rejected.
Argumente
| Name | Typ | Was sie bewirkt |
|---|---|---|
cache | table | nil | Evaluation-pass cache passed to getCached, or nil to read directly. |
method | function | API to call, such as UnitHealth or UnitPowerMax. |
unit | string | Unit token to read. |
power | boolean | nil | Truthy to read mana. |
Rückgabewerte
| 1 | number | nil | The reading, or nil when unavailable. |
|---|---|---|
| 2 | string | nil | Reason for nil: missing-api, api-error, restricted-value or statistic-unavailable. |
Editionen
Integrierte Hilfsfunktionen werden auf jeder Edition registriert. Unterschiedlich ist die Spiel-API, die sie lesen; fehlt eine, weicht die Hilfsfunktion aus oder gibt nil mit einem Grund zurück.
- Auf dieser Edition nicht verfügbar (den Grund nennt der Tooltip)
- Nur, solange Blizzards Ersatz für veraltete Funktionen aktiv ist
| Spiel-API | |||||
|---|---|---|---|---|---|
Enum.PowerType |
Geheime Werte (Retail und Forever)
Auf Retail und Forever übergibt das Spiel Addons geheime Werte. Diese Hilfsfunktion prüft, was sie liest (addon.Platform:CanReadValue), und gibt statt eines geheimen Werts, den sie nicht vergleichen kann, nil mit einem Grund wie restricted-value zurück. Behandeln Sie nil als nicht verfügbar, nicht als false.
Wie das Addon sie aufruft
Conditions.spatial_stats.statisticlocal current,reason=observation(cache,method,unit,mana)
Quelle
Conditions/spatial_stats.lua, Zeile 60. Im Spiel schreibgeschützt; Duplizieren erstellt eine bearbeitbare Kopie.
Conditions.spatial_stats.observation(cache, method, unit, power)
if type(method)~="function" then return nil,"missing-api" end
local ok,current
if power then ok,current=pcall(addon.getCached,cache,method,unit,Enum.PowerType.Mana)
else ok,current=pcall(addon.getCached,cache,method,unit) end
if not ok then return nil,"api-error" end
if not addon.Platform:CanReadValue(current) then return nil,"restricted-value" end
if type(current)~="number" or current~=current or current<0 or current==math.huge then return nil,"statistic-unavailable" end
return current




