Referencia › Referencia de funciones › Platform

Platform.spells.GetSpellCharges

pública

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

NombreTipoQué hace
selfRMPlatformAdaptador 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.
spellnumber | stringID de hechizo o nombre de hechizo reconocido por el cliente cuyas cargas se deben leer.

Retornos

1table | nilRegistro de cargas legible, o nil si no está disponible.
2string | nilMotivo 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 juegoClassic EraTBC AnniversaryClassic ProgressionForeverRetail
C_Spell.GetSpellChargesClassic EraTBC AnniversaryClassic ProgressionForeverRetail
GetSpellChargesClassic EraTBC AnniversaryClassic ProgressionForeverRetail

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.maxCharges

Dependencias

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

Volver a Referencia de funciones