호출 방법
addon.Platform:GetInspectRoleObservation(unit)
addon을 통해 바로 쓸 수 있으며, 의존성이 필요 없습니다.
하는 일
점검 또는 제한 정책 클라이언트에서 살펴보기 요청 없이 선택한 유닛의 역할을 관찰합니다. 유닛이 없는 것으로 알려지면 false를 반환합니다. 호출 가능한 최신 살펴보기 API를 우선하며, 그것이 없을 때만 이전 방식으로 대체합니다. 선택한 방식이 실패해도 다른 방식으로 넘어가지 않습니다. 양의 유한 정수 전문화 ID가 필요하며, 인수 하나인 정확한 GetSpecializationInfoByID 호출의 다섯 번째 반환값(역할)만 사용합니다. 필수 정보가 없거나, 실패하거나, 제한되거나, 잘못되면 사용할 수 없으며, 읽을 수 있는 비어 있지 않은 향후 역할 문자열은 그대로 유지합니다.
인수
| 이름 | 유형 | 하는 일 |
|---|---|---|
self | RMPlatform | Rotation Master 플랫폼 어댑터 (콜론 호출에서는 암묵적). |
unit | string | 선택한 비어 있지 않은 유닛 토큰. 기본 인수로 그대로 쓰입니다. |
반환값
| 1 | string | boolean | nil | 알려진 비어 있지 않은 역할 문자열, 없는 것으로 알려진 유닛이면 false, 사용할 수 없으면 nil. |
|---|---|---|
| 2 | string | nil | 정책, 기능 또는 필수 관찰 사용 불가 이유. |
버전
기본 제공 도우미는 모든 버전에 등록됩니다. 다른 점은 읽는 게임 API이며, API가 없으면 도우미는 대체 동작을 하거나 이유와 함께 nil을 반환합니다.
- 해당 버전에서 사용할 수 없음 (이유는 툴팁에 표시)
- Blizzard의 지원 중단 대체 함수가 켜져 있을 때만
| 게임 API | |||||
|---|---|---|---|---|---|
C_SpecializationInfo | |||||
GetInspectSpecialization | |||||
GetSpecializationInfoByID | |||||
UnitExists | |||||
canaccessvalue |
비공개 값 (Retail과 Forever)
Retail과 Forever에서는 게임이 애드온에 비공개 값을 넘깁니다. 이 도우미는 읽는 값을 확인하고(addon.Platform:CanReadValue), 비교할 수 없는 비공개 값 대신 restricted-value 같은 이유와 함께 nil을 반환합니다. nil은 거짓이 아니라 사용할 수 없음으로 취급하세요.
예시
local role = addon.Platform:GetInspectRoleObservation("target")
if role == nil then return nil end
return role == "HEALER"의존성
readField→Platform.role.readFieldroleValue→Platform.role.roleValue
소스
Platform/role.lua, 50번째 줄. 게임에서는 읽기 전용이며, 복제하면 편집 가능한 사본이 생깁니다.
Platform.role.GetInspectRoleObservation(self, unit)
local policy=self:GetCombatDataPolicy()
if policy~='probe' and policy~='restricted' then return nil,'unsupported-policy' end
if not self:CanReadValue(unit) then return nil,'restricted-value' end
if type(unit)~='string' or unit=='' then return nil,'invalid-unit' 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 namespace,reason=readField(self,_G,'C_SpecializationInfo')
if reason then return nil,reason end
local inspect
if namespace~=nil then
inspect,reason=readField(self,namespace,'GetInspectSpecialization')
if reason then return nil,reason end
end
if type(inspect)~='function' then
inspect,reason=readField(self,_G,'GetInspectSpecialization')
if reason then return nil,reason end
end
if type(inspect)~='function' then return nil,'missing-api' end
local ok,spec=pcall(inspect,unit)
if not ok then return nil,'api-error' end
if not self:CanReadValue(spec) then return nil,'restricted-value' end
if canaccessvalue and not canaccessvalue(spec) then return nil,'restricted-value' end
if spec==nil or spec==0 then return nil,'specialization-unavailable' end
if type(spec)~='number' or spec~=spec or spec>=math.huge or spec<=0 or spec%1~=0 then return nil,'invalid-api-result' end
local metadata
metadata,reason=readField(self,_G,'GetSpecializationInfoByID')
if reason then return nil,reason end
if type(metadata)~='function' then return nil,'missing-api' end
local roleOk,role=pcall(function() return (select(5,metadata(spec))) end)
if not roleOk then return nil,'api-error' end
return roleValue(self,role)




