Call as
addon.Platform:GetSpellCharges(spell)
Available directly through addon; no dependency is needed.
What it does
Read a normalized charge record: currentCharges, maxCharges, cooldownStartTime, cooldownDuration, chargeModRate and isActive. Unsupported spells or restricted client data return nil with a reason.
Arguments
| Name | Type | What it does |
|---|---|---|
self | RMPlatform | Rotation Master platform adapter. A dot reference requires addon.Platform as the first argument; a colon call supplies it implicitly. |
spell | number | string | Spell ID or client-recognized spell name whose charges should be read. |
Returns
| 1 | table | nil | Readable charge record, or nil when unavailable. |
|---|---|---|
| 2 | string | nil | Availability or validation reason when the record is nil. |
Editions
Built In helpers are registered on every edition. What differs is the game API they read; where one is missing the helper falls back or returns nil with a reason.
- Not available on that edition (the reason is in the tooltip)
- Only while Blizzard's deprecation fallbacks are on
| Game API | |||||
|---|---|---|---|---|---|
C_Spell.GetSpellCharges | |||||
GetSpellCharges |
Secret values (Retail and Forever)
On Retail and Forever the game hands addons secret values. This helper checks what it reads (addon.Platform:CanReadValue) and returns nil with a reason such as restricted-value instead of a secret it cannot compare. Treat nil as unavailable, not as false.
Example
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.maxChargesDependencies
chargeFields(builtin:Platform/spells.lua:chargeFields)identifier→Platform.spells.identifierown→Platform.spells.own
Source
Platform/spells.lua, line 616. Read only in game; Duplicate makes an editable copy.
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




