Llamar como
Conditions.weapon.swingSpeed(value, cache)
Registra la dependencia Conditions.weapon.swingSpeed y después llámala con ese nombre. Una llamada con espacio de nombres no pasa self: usa una llamada con dos puntos o pasa el objeto tú mismo.
Qué hace
Reads the player's main-hand, or off-hand when value.offhand is set, attack speed from the cached UnitAttackSpeed for the swing timer conditions. An off-hand check with no off-hand speed returns false.
Argumentos
| Nombre | Tipo | Qué hace |
|---|---|---|
value | table | Condition settings; a truthy offhand field selects the off hand. |
cache | table | nil | Evaluation-pass cache passed to getCached, or nil to read directly. |
Retornos
| 1 | number | boolean | nil | Swing speed in seconds, false when there is no off-hand weapon, or nil when unavailable. |
|---|---|---|
| 2 | string | nil | Reason for nil: missing-api, api-error, restricted-value or invalid-weapon-observation. |
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 | |||||
|---|---|---|---|---|---|
UnitAttackSpeed | |||||
UnitRangedDamage |
Cómo la llama el addon
- Tiempo de golpe del arma (evaluate)
local speed,reason=swingSpeed(value,cache) - Tiempo restante de golpe del arma (evaluate)
local speed,reason=swingSpeed(value,cache)
Dependencias
Functions.cache.getCached→Functions.cache.getCachedFunctions.presentation.compareString→Functions.presentation.compareStringFunctions.presentation.nullable→Functions.presentation.nullableFunctions.values.compare→Functions.values.compareFunctions.values.isin→Functions.values.isinnumericObservation→Conditions.weapon.numericObservation
Código fuente
Conditions/weapon.lua, línea 96. Solo lectura en el juego; Duplicar crea una copia editable.
Conditions.weapon.swingSpeed(value, cache)
-- Ranged: the Auto Shot or wand interval (UnitRangedDamage), false with no
-- ranged attack; the melee hands read UnitAttackSpeed.
if value.ranged then
local speed,reason=Functions.cache.getCached(cache,addon.Platform.GetRangedSwingSpeed,addon.Platform)
if speed==nil then return nil,reason end
return speed
end
if type(UnitAttackSpeed)~="function" then return nil,"missing-api" end
-- pcall forwards the mainhand and offhand speeds from the observation.
---@diagnostic disable-next-line: unbalanced-assignments
local ok,main,off=pcall(addon.getCached,cache,UnitAttackSpeed,"player")
if not ok then return nil,"api-error" end
local speed=main
if value.offhand then
speed=off
-- No off-hand weapon: the API returns no off-hand speed. That is a
-- reading (nothing to swing), so off-hand checks are false.
if speed==nil then return false end
end
return numericObservation(speed)




