호출 방법
addon.Platform:GetHealthForecastProviderObservation(unit)
addon을 통해 바로 쓸 수 있으며, 의존성이 필요 없습니다.
하는 일
인수 하나인 정확한 점 호출로 선택적인 RealMobHealth를 읽습니다. 네임스페이스가 없으면(nil/false) 빈 레코드를 반환합니다. current와 maximum을 따로 정규화하며, nil/false 필드는 기본 대체를 허용하고 숫자 0은 있는 값으로 간주합니다. 사용하는 제공자 정보가 잘못되었거나, 실패하거나, 제한되거나, 음수이거나, 유한하지 않으면 사용할 수 없습니다. 제공자 캐시나 오래된 대체 캐시는 사용하지 않습니다.
인수
| 이름 | 유형 | 하는 일 |
|---|---|---|
self | RMPlatform | Rotation Master 플랫폼 어댑터 (콜론 호출에서는 암묵적). |
unit | string | 제공자에 유일한 인수로 전달되는 선택한 유닛 토큰. |
반환값
| 1 | table | nil | 부분 current/maximum 레코드. 제공자가 없으면 비어 있고, 사용할 수 없으면 nil. |
|---|---|---|
| 2 | string | nil | 제공자, 검증 또는 관찰 사용 불가 이유. |
버전
기본 제공 도우미는 모든 버전에 등록됩니다. 다른 점은 읽는 게임 API이며, API가 없으면 도우미는 대체 동작을 하거나 이유와 함께 nil을 반환합니다.
게임 API를 직접 읽지 않습니다.
비공개 값 (Retail과 Forever)
Retail과 Forever에서는 게임이 애드온에 비공개 값을 넘깁니다. 이 도우미는 읽는 값을 확인하고(addon.Platform:CanReadValue), 비교할 수 없는 비공개 값 대신 restricted-value 같은 이유와 함께 nil을 반환합니다. nil은 거짓이 아니라 사용할 수 없음으로 취급하세요.
예시
local record = addon.Platform:GetHealthForecastProviderObservation("target")
if not record or not record.current or not record.maximum then return nil end
if record.maximum == 0 then return nil end
return record.current / record.maximum < 0.2의존성
providerValue→Platform.health_forecast.providerValuereadField→Platform.health_forecast.readField
소스
Platform/health_forecast.lua, 107번째 줄. 게임에서는 읽기 전용이며, 복제하면 편집 가능한 사본이 생깁니다.
Platform.health_forecast.GetHealthForecastProviderObservation(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
local provider=_G.RealMobHealth
if not self:CanReadValue(provider) then return nil,'restricted-value' end
if provider==nil or provider==false then return {} end
local api,why=readField(self,provider,'GetUnitHealth')
if why then return nil,why end
if type(api)~='function' then return nil,'missing-api' end
local ok,current,maximum=pcall(api,unit)
if not ok then return nil,'api-error' end
local value,reason=providerValue(self,current)
if reason then return nil,reason end
local max,maxReason=providerValue(self,maximum)
if maxReason then return nil,maxReason end
return {current=value,maximum=max}