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

Platform.unit_metadata.GetUnitMetadataObservation

공개

호출 방법

addon.Platform:GetUnitMetadataObservation(unit, kind)

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

하는 일

UnitExists를 확인한 뒤 사용하는 기본 유닛 메타데이터 필드 하나를 관찰합니다. class는 UnitClass의 두 번째 반환값, creature는 현지화된 UnitCreatureType 이름, classification은 UnitClassification을 사용합니다. 없다고 읽힌 유닛은 메타데이터를 조회하지 않고 false를 반환합니다. 사용하지 않는 튜플 필드는 사용 가능 여부에 영향을 주지 않으며, 필수 값이 없거나, 실패하거나, nil이거나, 제한되거나, 잘못되면 nil과 이유를 반환합니다. 플레이어 직업, GUID, 열거형, 번역 추론은 추가하지 않습니다.

인수

이름유형하는 일
selfRMPlatformRotation Master 플랫폼 어댑터 (콜론 호출에서는 암묵적).
unitstring존재 여부를 확인하고 선택한 메타데이터 API에 전달하는 정확한 유닛 토큰.
kindstringclass, creature, classification 중 하나. 다른 메타데이터 종류는 지원하지 않습니다.

반환값

1string | boolean | nil읽을 수 있는 사용 메타데이터 문자열, 없는 것으로 알려진 유닛이면 false, 필수 데이터를 사용할 수 없으면 nil.
2string | nilnil인 메타데이터 관찰에 대한 정책, 조회 검증 또는 사용 불가 이유.

버전

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

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

비공개 값 (Retail과 Forever)

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

예시

local classification = addon.Platform:GetUnitMetadataObservation("target", "classification")
if classification == nil then return nil end
return classification == "worldboss" or classification == "elite"

소스

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

Platform.unit_metadata.GetUnitMetadataObservation(self, unit, kind)
    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(kind) then return nil,'restricted-value' end
    if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
    if kind~='class' and kind~='creature' and kind~='classification' then return nil,'invalid-unit-metadata-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 false end
    local api
    if kind=='class' then api=UnitClass
    elseif kind=='creature' then api=UnitCreatureType
    else api=UnitClassification end
    if type(api)~='function' then return nil,'missing-api' end
    local ok,observed
    if kind=='class' then ok,observed=pcall(function() return select(2,api(unit)) end)
    else ok,observed=pcall(api,unit) end
    if not ok then return nil,'api-error' end
    if not self:CanReadValue(observed) then return nil,'restricted-value' end
    if observed==nil then return nil,'unit-metadata-unavailable' end
    if type(observed)~='string' or observed=='' then return nil,'invalid-api-result' end
    return observed

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