呼叫方式
addon.Platform:GetZonePVPObservation()
可直接透過 addon 使用,不需要相依項目。
作用
使用一次受保護的無參數點號呼叫,觀測區域 PvP 分類的第一個結果。優先使用可呼叫的 C_PvP.GetZonePVPInfo,僅當現代 API 不可呼叫時才使用全域輔助函式。成功傳回 nil 或沒有傳回值時,會產生一個已知的空記錄;缺少、失敗、受限或格式錯誤的觀測維持為無法使用。可讀的空字串與未來字串保留其確切含義,未使用的傳回欄位不決定可用性。在現代 API 傳回結果或失敗後,絕不切換後端。
參數
| 名稱 | 類型 | 作用 |
|---|---|---|
self | RMPlatform | Rotation Master 平台轉接器(使用冒號呼叫時隱含傳入)。 |
傳回值
| 1 | table | nil | 成功的觀測記錄,pvpType 為字串或 nil;記錄為 nil 表示無法使用。 |
|---|---|---|
| 2 | string | nil | 記錄為 nil 時的用戶端政策、功能、呼叫或觀測可用性原因。 |
版本
內建輔助函式在每個版本上都會註冊。不同的是它們讀取的遊戲 API;某個 API 不存在時,輔助函式會改用備用方式,或傳回 nil 並附上原因。
- 該版本無法使用(原因請見提示)
- 僅在暴雪的棄用相容層開啟時
| 遊戲 API | |||||
|---|---|---|---|---|---|
C_PvP | |||||
GetZonePVPInfo | |||||
canaccessvalue |
機密值(正式版與永久)
在正式版與永久上,遊戲交給插件的是機密值。此輔助函式會檢查它讀取的內容(addon.Platform:CanReadValue),遇到無法比較的機密值時,會傳回 nil 並附上原因(例如 restricted-value),而不是傳回該機密值。請將 nil 視為無法使用,而非假。
範例
local zone = addon.Platform:GetZonePVPObservation()
if not zone then return nil end
return zone.pvpType == "sanctuary"原始碼
Platform/zone_pvp.lua,第 18 行。在遊戲中為唯讀;「複製」會產生一份可編輯的複本。
Platform.zone_pvp.GetZonePVPObservation(self)
local family=self:GetClientFamily()
if family~='retail' and family~='forever' and family~='era' and family~='tbc' and family~='progression' then return nil,'unsupported-policy' end
local namespace=C_PvP
if not self:CanReadValue(namespace) then return nil,'restricted-value' end
if canaccessvalue and not canaccessvalue(namespace) then return nil,'restricted-value' end
local api
if type(namespace)=='table' then api=namespace.GetZonePVPInfo end
if not self:CanReadValue(api) then return nil,'restricted-value' end
if canaccessvalue and not canaccessvalue(api) then return nil,'restricted-value' end
if type(api)~='function' then
api=GetZonePVPInfo
if not self:CanReadValue(api) then return nil,'restricted-value' end
if canaccessvalue and not canaccessvalue(api) then return nil,'restricted-value' end
if type(api)~='function' then return nil,'missing-api' end
end
local ok,pvpType=pcall(api)
if not ok then return nil,'api-error' end
if not self:CanReadValue(pvpType) then return nil,'restricted-value' end
if canaccessvalue and not canaccessvalue(pvpType) then return nil,'restricted-value' end
if pvpType==nil then return {} end
if type(pvpType)~='string' then return nil,'invalid-api-result' end
return {pvpType=pvpType}




