Chiamala come
Conditions.weapon.swingSpeed(value, cache)
Registra la dipendenza Conditions.weapon.swingSpeed, poi chiamala con quel nome. Una chiamata con spazio dei nomi non passa self: usa una chiamata con i due punti o passa tu l'oggetto.
Cosa fa
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.
Argomenti
| Nome | Tipo | Cosa fa |
|---|---|---|
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. |
Valori restituiti
| 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. |
Edizioni
Le funzioni di supporto integrate sono registrate su ogni edizione. Ciò che cambia è l'API di gioco che leggono; dove ne manca una, la funzione di supporto ripiega su un'alternativa o restituisce nil con un motivo.
- Non disponibile su quell'edizione (il motivo è nel suggerimento)
- Solo mentre sono attivi i ripieghi di Blizzard per le API deprecate
| API di gioco | |||||
|---|---|---|---|---|---|
UnitAttackSpeed | |||||
UnitRangedDamage |
Come la chiama l'addon
- Tempo dell'attacco dell'arma (evaluate)
local speed,reason=swingSpeed(value,cache) - Tempo rimanente all'attacco dell'arma (evaluate)
local speed,reason=swingSpeed(value,cache)
Dipendenze
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
Sorgente
Conditions/weapon.lua, riga 96. Nel gioco è in sola lettura; Duplica crea una copia modificabile.
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)




