레퍼런스 › 함수 레퍼런스 › Platform

Platform.spells.GetSpellCooldown

공개

호출 방법

addon.Platform:GetSpellCooldown(spell)

addon을 통해 바로 쓸 수 있으며, 의존성이 필요 없습니다.

하는 일

지원되는 클라이언트 전반에서 주문 재사용 대기시간을 읽고 정규화합니다. 반환되는 레코드에는 startTime, duration, isEnabled, modRate가 들어 있습니다. 타임스탬프와 duration은 이미 GetTime() 초 단위의 만료를 나타내므로 modRate로 나누지 마세요. 클라이언트가 시간을 숨기면(전투 중 Retail과 Forever) 레코드는 nil이고 이유는 restricted-value이며, 읽을 수 있으면 항상 공개되는 isEnabled, isActive, isOnGCD 플래그가 뒤따릅니다.

인수

이름유형하는 일
selfRMPlatformRotation Master 플랫폼 어댑터. 점 참조는 첫 번째 인수로 addon.Platform이 필요하며, 콜론 호출은 이를 암묵적으로 전달합니다.
spellnumber | string재사용 대기시간을 읽을 주문 ID 또는 클라이언트가 인식하는 주문 이름.

반환값

1table | nil읽을 수 있는 재사용 대기시간 레코드. 사용할 수 없으면 nil.
2string | nil기록이 nil일 때의 사용 불가 또는 검증 이유.
3boolean | nilrestricted-value일 때만: isEnabled, 재사용 대기시간이 보류 중인 동안 false.
4boolean | nilrestricted-value일 때만: isActive, 재사용 대기시간(자체 또는 전역)이 진행 중인 동안 true.
5boolean | nilrestricted-value일 때만: isOnGCD, 진행 중인 재사용 대기시간이 전역 재사용 대기시간이면 true. nil일 수 있습니다.

버전

기본 제공 도우미는 모든 버전에 등록됩니다. 다른 점은 읽는 게임 API이며, API가 없으면 도우미는 대체 동작을 하거나 이유와 함께 nil을 반환합니다.

  • 해당 버전에서 사용할 수 없음 (이유는 툴팁에 표시)
  • Blizzard의 지원 중단 대체 함수가 켜져 있을 때만
게임 APIClassic EraTBC AnniversaryClassic progressionForeverRetail
C_Spell.GetSpellCooldownClassic EraTBC AnniversaryClassic progressionForeverRetail
GetSpellCooldownClassic EraTBC AnniversaryClassic progressionForeverRetail

비공개 값 (Retail과 Forever)

Retail과 Forever에서는 게임이 애드온에 비공개 값을 넘깁니다. 이 도우미는 읽는 값을 확인하고(addon.Platform:CanReadValue), 비교할 수 없는 비공개 값 대신 restricted-value 같은 이유와 함께 nil을 반환합니다. nil은 거짓이 아니라 사용할 수 없음으로 취급하세요.

예시

local record, reason, isEnabled, isActive = addon.Platform:GetSpellCooldown(value.spell)
if record then return record.isEnabled and record.duration == 0 end
-- Times are secret in combat on Retail and Forever; fall back to the flags.
if reason == "restricted-value" and isActive ~= nil then return isEnabled and not isActive end
return nil

의존성

소스

Platform/spells.lua, 393번째 줄. 게임에서는 읽기 전용이며, 복제하면 편집 가능한 사본이 생깁니다.

Platform.spells.GetSpellCooldown(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.GetSpellCooldown) == "function" then
        ok, record = pcall(C_Spell.GetSpellCooldown, spell)
    elseif type(GetSpellCooldown) == "function" then
        local start, duration, enabled, rate
        ok, start, duration, enabled, rate = pcall(GetSpellCooldown, spell)
        if not ok then return nil, "api-error" end
        if not self:CanReadValue(start) or not self:CanReadValue(duration) or not self:CanReadValue(enabled)
            or not self:CanReadValue(rate) then return nil, "restricted-value" end
        if start ~= nil then
            if enabled ~= 0 and enabled ~= 1 then return nil, "invalid-api-result" end
            record = {startTime=start, duration=duration, isEnabled=enabled == 1, modRate=rate or 1};built = true
        end
    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-data-unavailable" end
    local cooldown, why = own(record, cooldownFields, built)
    if not cooldown then
        if why == "restricted-value" and not built then return nil, why, cooldownFlags(self, record) end
        return nil, why
    end
    if cooldown.startTime == nil or cooldown.duration == nil or cooldown.isEnabled == nil
        or cooldown.startTime < 0 or cooldown.duration < 0 or (cooldown.modRate and cooldown.modRate <= 0) then
        return nil, "invalid-api-result"
    end
    cooldown.modRate = cooldown.modRate or 1
    return cooldown

함수 레퍼런스(으)로 돌아가기