Chiamala come
addon.Platform:GetSpellCharges(spell)
Disponibile direttamente tramite addon; non serve alcuna dipendenza.
Cosa fa
Legge un record normalizzato delle cariche: currentCharges, maxCharges, cooldownStartTime, cooldownDuration, chargeModRate e isActive. Incantesimi non supportati o dati del client soggetti a restrizioni restituiscono nil con un motivo.
Argomenti
| Nome | Tipo | Cosa fa |
|---|---|---|
self | RMPlatform | Adattatore di piattaforma di Rotation Master. Un riferimento con punto richiede addon.Platform come primo argomento; una chiamata con due punti lo fornisce implicitamente. |
spell | number | string | ID dell'incantesimo o nome riconosciuto dal client di cui leggere le cariche. |
Valori restituiti
| 1 | table | nil | Record leggibile delle cariche, oppure nil se non disponibile. |
|---|---|---|
| 2 | string | nil | Motivo di indisponibilità o di convalida quando il record è nil. |
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 | |||||
|---|---|---|---|---|---|
C_Spell.GetSpellCharges | |||||
GetSpellCharges |
Valori segreti (Retail e Forever)
Su Retail e Forever il gioco fornisce agli addon valori segreti. Questa funzione di supporto controlla ciò che legge (addon.Platform:CanReadValue) e restituisce nil con un motivo come restricted-value invece di un valore segreto che non può confrontare. Considera nil come non disponibile, non come false.
Esempio
local charges = addon.Platform:GetSpellCharges(value.spell)
if not charges then return nil end
-- spend a charge rather than waste recharge time
return charges.currentCharges == charges.maxChargesDipendenze
chargeFields(builtin:Platform/spells.lua:chargeFields)identifier→Platform.spells.identifierown→Platform.spells.own
Sorgente
Platform/spells.lua, riga 616. Nel gioco è in sola lettura; Duplica crea una copia modificabile.
Platform.spells.GetSpellCharges(self, spell)
local valid,reason=identifier(spell)
if not valid then return nil,reason end
local ok,record,built
if C_Spell and type(C_Spell.GetSpellCharges)=="function" then
ok,record=pcall(C_Spell.GetSpellCharges,spell)
elseif type(GetSpellCharges)=="function" then
local current,maximum,start,duration,rate
ok,current,maximum,start,duration,rate=pcall(GetSpellCharges,spell)
if not ok then return nil,"api-error" end
record={currentCharges=current,maxCharges=maximum,cooldownStartTime=start,cooldownDuration=duration,chargeModRate=rate};built=true
else return nil,"missing-api" end
if not ok then return nil,"api-error" end
if not self:CanReadValue(record) then return nil,"restricted-value" end
if record==nil then return nil,"spell-charges-unavailable" end
local charges,why=own(record,chargeFields,built)
if not charges then return nil,why end
if next(charges)==nil then return nil,"spell-charges-unavailable" end
local current,maximum,start,duration=charges.currentCharges,charges.maxCharges,charges.cooldownStartTime,charges.cooldownDuration
if current==nil or maximum==nil or start==nil or duration==nil or current<0 or current%1~=0
or maximum<1 or maximum%1~=0 or current>maximum or start<0 or duration<0
or charges.chargeModRate and charges.chargeModRate<=0 then return nil,"invalid-api-result" end
local active=current<maximum and start>0 and duration>0
if charges.isActive==nil then charges.isActive=active
elseif charges.isActive and not active then return nil,"invalid-api-result" end
charges.chargeModRate=charges.chargeModRate or 1
return charges




