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

Platform.unit_stat.GetUnitStatObservation

공개

호출 방법

addon.Platform:GetUnitStatObservation(unit, stat)

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

하는 일

기본 반환값 두 번째에서만 유효 능력치를 관찰합니다. 점검 또는 제한 정책 클라이언트에서 정확한 UnitExists(unit)를 조회한 뒤, 선택자 1..5는 UnitStat(unit,stat), 선택자 6은 UnitArmor(unit)를 조회합니다. 없는 것으로 알려지면 exists=false를 반환하며, 필수 정보가 없거나, 실패하거나, 제한되거나, 유한하지 않으면 nil을 반환합니다. 유한한 부호 있는 값, 소수, 0을 보존하고, 사용하지 않는 튜플 필드는 모두 무시합니다. 1..6 경로는 RM 선택자 정책이며 기본 값 범위의 제한이 아닙니다.

인수

이름유형하는 일
selfRMPlatformRotation Master 플랫폼 어댑터 (콜론 호출에서는 암묵적).
unitstring기본 호출에 그대로 쓰이는 선택한 비어 있지 않은 유닛 토큰.
statnumberRM 능력치 정수 선택자 1..5, 또는 유효 방어도는 6.

반환값

1table | nilexists=false이거나, exists=true와 유한한 value를 담은 레코드. 사용할 수 없으면 nil.
2string | nil조회, 정책 또는 관찰 사용 불가 이유.

버전

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

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

비공개 값 (Retail과 Forever)

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

예시

local armor = addon.Platform:GetUnitStatObservation("player", 6)
if not armor or not armor.exists then return nil end
return armor.value >= 10000

의존성

소스

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

Platform.unit_stat.GetUnitStatObservation(self, unit, stat)
    local policy=self:GetCombatDataPolicy()
    if policy~='probe' and policy~='restricted' then return nil,'unsupported-policy' end
    if not self:CanReadValue(unit) or not self:CanReadValue(stat) then return nil,'restricted-value' end
    if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
    if not finite(stat) or stat%1~=0 or stat<1 or stat>6 then return nil,'invalid-stat-query' end
    if type(UnitExists)~='function' then return nil,'missing-api' end
    local existsOk,exists=pcall(UnitExists,unit)
    if not existsOk then return nil,'api-error' end
    if not self:CanReadValue(exists) then return nil,'restricted-value' end
    if exists==nil then return nil,'unit-data-unavailable' end
    if type(exists)~='boolean' then return nil,'invalid-api-result' end
    if not exists then return {exists=false} end
    local fn
    if stat==6 then fn=UnitArmor else fn=UnitStat end
    if type(fn)~='function' then return nil,'missing-api' end
    local ok,_,effective
    if stat==6 then ok,_,effective=pcall(fn,unit)
    else ok,_,effective=pcall(fn,unit,stat) end
    if not ok then return nil,'api-error' end
    if not self:CanReadValue(effective) then return nil,'restricted-value' end
    if canaccessvalue and not canaccessvalue(effective) then return nil,'restricted-value' end
    if effective==nil then return nil,'stat-data-unavailable' end
    if not finite(effective) then return nil,'invalid-api-result' end
    return {exists=true,value=effective}

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