Llamar como
addon.Platform:GetSpellCharges(spell)
Disponible directamente a través de addon; no hace falta ninguna dependencia.
Qué hace
Lee un registro de cargas normalizado: currentCharges, maxCharges, cooldownStartTime, cooldownDuration, chargeModRate e isActive. Los hechizos no compatibles o los datos restringidos del cliente devuelven nil con un motivo.
Argumentos
| Nombre | Tipo | Qué hace |
|---|---|---|
self | RMPlatform | Adaptador de plataforma de Rotation Master. Una referencia con punto requiere addon.Platform como primer argumento; una llamada con dos puntos lo proporciona de forma implícita. |
spell | number | string | ID de hechizo o nombre de hechizo reconocido por el cliente cuyas cargas se deben leer. |
Retornos
| 1 | table | nil | Registro de cargas legible, o nil si no está disponible. |
|---|---|---|
| 2 | string | nil | Motivo de disponibilidad o de validación cuando el registro es nil. |
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 recurre a 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 | |||||
|---|---|---|---|---|---|
C_Spell.GetSpellCharges | |||||
GetSpellCharges |
Valores secretos (Retail y Forever)
En Retail y Forever, el juego entrega a los addons valores secretos. Esta función auxiliar comprueba lo que lee (addon.Platform:CanReadValue) y, en lugar de un secreto que no puede comparar, devuelve nil con un motivo como restricted-value. Trata nil como no disponible, no como falso.
Ejemplo
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.maxChargesDependencias
chargeFields(builtin:Platform/spells.lua:chargeFields)identifier→Platform.spells.identifierown→Platform.spells.own
Código fuente
Platform/spells.lua, línea 616. Solo lectura en el juego; Duplicar crea una copia editable.
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




