Call as
Conditions.weapon.numericObservation(value)
Record the dependency Conditions.weapon.numericObservation, then call it by that name. A namespaced call does not pass self: use a colon call or pass the object yourself.
What it does
Accepts a readable, nonnegative, finite number from a weapon observation and returns it unchanged; anything else becomes nil with a reason.
Arguments
| Name | Type | What it does |
|---|---|---|
value | any | Observed value, such as an expiration time or swing speed. |
Returns
| 1 | number | nil | The value, or nil when it is not usable. |
|---|---|---|
| 2 | string | nil | Reason for nil: restricted-value or invalid-weapon-observation. |
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.
How the addon calls it
- Weapon Enchant Time Remaining (evaluate)
local duration,why=numericObservation(expires) - Weapon Enchant Stacks (evaluate)
local count,why=numericObservation(charges) Conditions.weapon.swingSpeedreturn numericObservation(speed)
Source
Conditions/weapon.lua, line 81. Read only in game; Duplicate makes an editable copy.
Conditions.weapon.numericObservation(value)
if not addon.Platform:CanReadValue(value) then return nil,"restricted-value" end
if type(value)~="number" or value~=value or value<0 or value==math.huge then return nil,"invalid-weapon-observation" end
return value