參考資料 › 函式參考 › Functions

Functions.presentation.phrase

公用

呼叫方式

Functions.presentation.phrase(template, values)

將它記錄為名為 Functions.presentation.phrase 的相依項目(接受自動完成即可完成此步驟),然後以該名稱呼叫。

作用

建立一個暫時的具名條件摘要。純量值使用 {name},判斷的正反兩種措辭使用 {{positive|negative}};在主要措辭前加上 ! 前綴。字面的雙大括號請跳脫為 {{{{ 和 }}}}。值會依字面插入,不解析其中的百分號、連結、顏色或大括號。具型別的判斷值會參與主要措辭的選擇。範本、值與繪製後的文字都有長度上限;格式錯誤的輸入會繪製為在地化的「無法使用」摘要。這只改變呈現方式,不會執行任何條件觀測。

參數

名稱類型作用
templatestring帶有命名欄位與選擇性的明確判斷備選項的在地化完整句子。
valuestable以識別碼為鍵的純量值或具型別的判斷。支援字串、有限數字與布林值;被參照的欄位必須存在。值在建立短語時被擷取。

傳回值

1RMConditionPhrase條件摘要繪製所辨識的暫時可信短語;不要將其作為條件資料儲存。

版本

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

它不會直接讀取任何遊戲 API。

插件如何呼叫它

  • 存在增益效果 (print)
    return AuraLiteral.phrase(Functions.presentation.playerize(value.unit, L["{unit} {{!have|do not have}} {aura}"], L["{unit} {{!has|does not have}} {aura}"]), {
  • 增益效果剩餘時間 (print)
    return AuraSummary.phrase(Functions.presentation.playerize(value.unit, L["{unit} {{!have|do not have}} {aura} where {remaining} {comparison} {duration}"], L["{unit} {{!has|does not have}} {aura} where {remaining} {comparison} {duration}"]), {
  • 增益效果層數 (print)
    return AuraSummary.phrase(L["the number of stacks of {aura} on {unit} {comparison} {quantity}"], {
  • 背包中有物品 (print)
    return Summary.phrase(L["the number of {item} you are carrying {comparison} {quantity}"], {
  • 施放特定法術 (print)
    return LiteralSummary.phrase(Functions.presentation.playerize(value.unit, L["{unit} {{!are|are not}} currently casting {spell}"], L["{unit} {{!is|is not}} currently casting {spell}"]), {
  • 引導特定法術 (print)
    return LiteralSummary.phrase(Functions.presentation.playerize(value.unit, L["{unit} {{!are|are not}} currently channeling {spell}"], L["{unit} {{!is|is not}} currently channeling {spell}"]), {
  • 存在減益效果 (print)
    return AuraLiteral.phrase(Functions.presentation.playerize(value.unit, L["{unit} {{!have|do not have}} {aura}"], L["{unit} {{!has|does not have}} {aura}"]), {
  • 減益效果剩餘時間 (print)
    return AuraSummary.phrase(Functions.presentation.playerize(value.unit, L["{unit} {{!have|do not have}} {aura} where {remaining} {comparison} {duration}"], L["{unit} {{!has|does not have}} {aura} where {remaining} {comparison} {duration}"]), {

以及另外 18 處: 減益效果層數 (print), 擴充角色屬性 (print), 擴充角色屬性百分比 (print), 已裝備物品 (print), 物品可用 (print), 物品冷卻 (print), 物品在射程內 (print), 擁有指定名稱的寵物 (print), 範圍內的生命力 (print), 範圍內的生命力百分比 (print), 範圍內的生命力百分比計數 (print), 範圍內的生命力計數 (print), 範圍內的法力 (print), 範圍內的法力百分比 (print), 範圍內的法力百分比計數 (print), 範圍內的法力計數 (print), 已裝備的套裝件數 (print), 區域 (print)

原始碼

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

Functions.presentation.phrase(template, values)
    return addon:CreateConditionSummaryPhrase(template, values)

返回函式參考