Как вызывать
Conditions.spatial.booleanRead(cache, method, ...)
Запишите зависимость Conditions.spatial.booleanRead и вызывайте её по этому имени. Вызов через пространство имён не передаёт self: используйте вызов через двоеточие или передайте объект сами.
Что делает
Calls a yes/no game API through the evaluation cache, protected against errors, for the distance conditions. Accepts nil, false and 0 as no and true and 1 as yes; a missing API, an error, a restricted value or any other answer gives nil with a reason.
Аргументы
| Имя | Тип | Что делает |
|---|---|---|
cache | table | nil | Evaluation-pass cache passed to getCached, or nil to read directly. |
method | function | Game API to call, such as UnitExists or UnitIsEnemy. |
... | any | Arguments forwarded to method. |
Возвращает
| 1 | boolean | nil | The answer, or nil when it cannot be read. |
|---|---|---|
| 2 | string | nil | Reason for nil: missing-api, api-error, restricted-value or invalid-api-result. |
Издания
Встроенные помощники регистрируются во всех изданиях. Различается игровой API, который они читают; если нужного API нет, помощник использует запасной вариант или возвращает nil с причиной.
Не читает игровой API напрямую.
Секретные значения (Retail и Forever)
В Retail и Forever игра передаёт аддонам секретные значения. Этот помощник проверяет то, что читает (addon.Platform:CanReadValue), и вместо секретного значения, которое нельзя сравнить, возвращает nil с причиной, например restricted-value. Считайте nil недоступным значением, а не ложью.
Как его вызывает аддон
- Число в радиусе (evaluate)
local present,issue=booleanRead(cache,UnitExists,entity.unit) Conditions.spatial.combatFilterlocal fighting,why=booleanRead(cache,UnitAffectingCombat,unit)Conditions.spatial.nameplateDistanceCountlocal present,issue=booleanRead(cache,UnitExists,unit)
Зависимости
protectedRead→Conditions.spatial.protectedRead
Исходный код
Conditions/spatial.lua, строка 73. В игре только для чтения; «Дублировать» создаёт редактируемую копию.
Conditions.spatial.booleanRead(cache, method, ...)
local ok,result=protectedRead(cache,method,...)
if not ok then return nil,result=="missing-api" and result or "api-error" end
if not addon.Platform:CanReadValue(result) then return nil,"restricted-value" end
if result==nil or result==false or result==0 then return false end
if result==true or result==1 then return true end
return nil,"invalid-api-result"