參考資料 › 函式參考 › Platform

Platform.points.GetPlayerComboPointObservation

公用

呼叫方式

addon.Platform:GetPlayerComboPointObservation(powerType, kind)

可直接透過 addon 使用,不需要相依項目。

作用

觀測明確選擇的 TBC 玩家連擊點傳輸方式。current 只使用 GetComboPoints(player,target);maximum 使用帶原始選擇器的 UnitPowerMax(player,powerType)。其他用戶端系列在此無法使用,必須使用其現有的點數能量觀測器。保留可讀的有限帶正負號、小數與零值。缺少、失敗、受限或格式錯誤的資料維持為無法使用;所選的連擊點查詢失敗時絕不會改用 UnitPower。這不會觀測其他角色,也不會新增快取。

參數

名稱類型作用
selfRMPlatformRotation Master 平台轉接器(使用冒號呼叫時隱含傳入)。
powerTypenumber原始的明確、可讀、有限的非負整數連擊資源選擇器(包括零);保留用於最大值查詢。
kindstring只能是 current(對應玩家/目標連擊點查詢)或 maximum(對應玩家上限查詢)。

傳回值

1number | nil有限的原生資源數量,保留其正負號與小數部分;無法使用時為 nil。
2string | nil數量為 nil 時的政策、查詢驗證或所需觀測的可用性原因。

版本

內建輔助函式在每個版本上都會註冊。不同的是它們讀取的遊戲 API;某個 API 不存在時,輔助函式會改用備用方式,或傳回 nil 並附上原因。

  • 該版本無法使用(原因請見提示)
  • 僅在暴雪的棄用相容層開啟時
遊戲 API經典時代TBC 週年版經典進程永久正式版
GetComboPoints經典時代TBC 週年版經典進程永久正式版
UnitPowerMax經典時代TBC 週年版經典進程永久正式版
canaccessvalue經典時代TBC 週年版經典進程永久正式版

機密值(正式版與永久)

在正式版與永久上,遊戲交給插件的是機密值。此輔助函式會檢查它讀取的內容(addon.Platform:CanReadValue),遇到無法比較的機密值時,會傳回 nil 並附上原因(例如 restricted-value),而不是傳回該機密值。請將 nil 視為無法使用,而非假。

範例

-- TBC only; 4 is the combo point power type
local current = addon.Platform:GetPlayerComboPointObservation(4, "current")
if current == nil then return nil end
return current >= 5

原始碼

Platform/points.lua,第 216 行。在遊戲中為唯讀;「複製」會產生一份可編輯的複本。

Platform.points.GetPlayerComboPointObservation(self, powerType, kind)
    local info=self:GetClientInfo()
    if info.combatDataPolicy~='probe' then return nil,'unsupported-policy' end
    local family
    if self:CanReadValue(info) and type(info)=='table' then family=rawget(info,'family') end
    if not self:CanReadValue(family) then return nil,'restricted-value' end
    if canaccessvalue and not canaccessvalue(family) then return nil,'restricted-value' end
    if family~='tbc' then return nil,'unsupported-point-transport' end
    if not self:CanReadValue(powerType) or not self:CanReadValue(kind) then return nil,'restricted-value' end
    if type(powerType)~='number' or powerType~=powerType or powerType<0 or powerType==math.huge or powerType%1~=0 then return nil,'invalid-point-power-query' end
    if kind~='current' and kind~='maximum' then return nil,'invalid-point-power-query' end
    local api
    if kind=='current' then api=GetComboPoints else api=UnitPowerMax end
    if type(api)~='function' then return nil,'missing-api' end
    local ok,result
    if kind=='current' then ok,result=pcall(api,'player','target') else ok,result=pcall(api,'player',powerType) end
    if not ok then return nil,'api-error' end
    if not self:CanReadValue(result) then return nil,'restricted-value' end
    if canaccessvalue and not canaccessvalue(result) then return nil,'restricted-value' end
    if result==nil then return nil,'point-power-unavailable' end
    if type(result)~='number' or result~=result or result==math.huge or result==-math.huge then return nil,'invalid-api-result' end
    return result

返回函式參考