Chame como
addon.Platform:GetSpellCharges(spell)
Disponível diretamente por meio de addon; nenhuma dependência é necessária.
O que faz
Lê um registro de cargas normalizado: currentCharges, maxCharges, cooldownStartTime, cooldownDuration, chargeModRate e isActive. Feitiços não suportados ou dados restritos do cliente retornam nil com um motivo.
Argumentos
| Nome | Tipo | O que faz |
|---|---|---|
self | RMPlatform | Adaptador de plataforma do Rotation Master. Uma referência com ponto exige addon.Platform como primeiro argumento; uma chamada com dois-pontos o fornece implicitamente. |
spell | number | string | ID de feitiço ou nome de feitiço reconhecido pelo cliente cujas cargas devem ser lidas. |
Retornos
| 1 | table | nil | Registro de cargas legível, ou nil quando indisponível. |
|---|---|---|
| 2 | string | nil | Motivo de disponibilidade ou de validação quando o registro é nil. |
Edições
As funções auxiliares integradas são registradas em todas as edições. O que muda é a API do jogo que elas leem; quando uma está ausente, a função auxiliar recorre a uma alternativa ou retorna nil com um motivo.
- Indisponível nessa edição (o motivo está na dica)
- Só enquanto as alternativas da Blizzard para APIs obsoletas estiverem ativas
| API do jogo | |||||
|---|---|---|---|---|---|
C_Spell.GetSpellCharges | |||||
GetSpellCharges |
Valores secretos (Retail e Forever)
No Retail e no Forever, o jogo entrega valores secretos aos addons. Esta função auxiliar verifica o que lê (addon.Platform:CanReadValue) e retorna nil com um motivo como restricted-value em vez de um valor secreto que não consegue comparar. Trate nil como indisponível, não como false.
Exemplo
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.maxChargesDependências
chargeFields(builtin:Platform/spells.lua:chargeFields)identifier→Platform.spells.identifierown→Platform.spells.own
Código-fonte
Platform/spells.lua, linha 616. Somente leitura no jogo; Duplicar cria uma cópia editável.
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




