호출 방법
addon.Platform:GetSpellCharges(spell)
addon을 통해 바로 쓸 수 있으며, 의존성이 필요 없습니다.
하는 일
정규화된 충전 레코드(currentCharges, maxCharges, cooldownStartTime, cooldownDuration, chargeModRate, isActive)를 읽습니다. 지원되지 않는 주문이나 제한된 클라이언트 데이터는 nil과 이유를 반환합니다.
인수
| 이름 | 유형 | 하는 일 |
|---|---|---|
self | RMPlatform | Rotation Master 플랫폼 어댑터. 점 참조는 첫 번째 인수로 addon.Platform이 필요하며, 콜론 호출은 이를 암묵적으로 전달합니다. |
spell | number | string | 충전을 읽을 주문 ID 또는 클라이언트가 인식하는 주문 이름. |
반환값
| 1 | table | nil | 읽을 수 있는 충전 레코드. 사용할 수 없으면 nil. |
|---|---|---|
| 2 | string | nil | 기록이 nil일 때의 사용 불가 또는 검증 이유. |
버전
기본 제공 도우미는 모든 버전에 등록됩니다. 다른 점은 읽는 게임 API이며, API가 없으면 도우미는 대체 동작을 하거나 이유와 함께 nil을 반환합니다.
- 해당 버전에서 사용할 수 없음 (이유는 툴팁에 표시)
- Blizzard의 지원 중단 대체 함수가 켜져 있을 때만
비공개 값 (Retail과 Forever)
Retail과 Forever에서는 게임이 애드온에 비공개 값을 넘깁니다. 이 도우미는 읽는 값을 확인하고(addon.Platform:CanReadValue), 비교할 수 없는 비공개 값 대신 restricted-value 같은 이유와 함께 nil을 반환합니다. nil은 거짓이 아니라 사용할 수 없음으로 취급하세요.
예시
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의존성
chargeFields(builtin:Platform/spells.lua:chargeFields)identifier→Platform.spells.identifierown→Platform.spells.own
소스
Platform/spells.lua, 616번째 줄. 게임에서는 읽기 전용이며, 복제하면 편집 가능한 사본이 생깁니다.
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




