Справочник › Справочник функций › Conditions

Conditions.spatial.nameplateDistanceCount

зависимость

Как вызывать

Conditions.spatial.nameplateDistanceCount(value, cache, plates)

Запишите зависимость Conditions.spatial.nameplateDistanceCount и вызывайте её по этому имени. Вызов через пространство имён не передаёт self: используйте вызов через двоеточие или передайте объект сами.

Что делает

Counts units for DISTANCE_COUNT from a nameplate unit snapshot: units that exist, whose hostility matches value.enemy, and that are definitely within value.distance yards. Compares the count with value.operator and value.value; any unreadable unit or uncertain range makes the whole result unavailable.

Аргументы

ИмяТипЧто делает
valuetableCondition settings: enemy, distance, operator and value.
cachetable | nilEvaluation-pass cache passed to getCached, or nil to read directly.
platestableSnapshot whose keys are nameplate unit tokens.

Возвращает

1boolean | nilResult of the count comparison, or nil when the count cannot be established.
2string | nilReason for nil, such as unit-snapshot-unavailable, invalid-unit-snapshot, restricted-value or range-uncertain.

Издания

Встроенные помощники регистрируются во всех изданиях. Различается игровой API, который они читают; если нужного API нет, помощник использует запасной вариант или возвращает nil с причиной.

  • Недоступно в этом издании (причина — во всплывающей подсказке)
  • Только пока включены запасные реализации Blizzard для устаревших функций
Игровой APIClassic EraTBC AnniversaryClassic ProgressionForeverRetail
UnitExistsClassic EraTBC AnniversaryClassic ProgressionForeverRetail
UnitIsEnemyClassic EraTBC AnniversaryClassic ProgressionForeverRetail

Секретные значения (Retail и Forever)

В Retail и Forever игра передаёт аддонам секретные значения. Этот помощник проверяет то, что читает (addon.Platform:CanReadValue), и вместо секретного значения, которое нельзя сравнить, возвращает nil с причиной, например restricted-value. Считайте nil недоступным значением, а не ложью.

Как его вызывает аддон

Зависимости

Исходный код

Conditions/spatial.lua, строка 690. В игре только для чтения; «Дублировать» создаёт редактируемую копию.

Conditions.spatial.nameplateDistanceCount(value, cache, plates)
    if type(plates)~="table" then return nil,"unit-snapshot-unavailable" end
    local count = 0
    for unit in pairs(plates) do
        if not addon.Platform:CanReadValue(unit) then return nil,"restricted-value" end
        if type(unit)~="string" or unit=="" then return nil,"invalid-unit-snapshot" end
        local present,issue=booleanRead(cache,UnitExists,unit)
        if present==nil then return nil,issue end
        if present then
            local enemy,problem=booleanRead(cache,UnitIsEnemy,"player",unit)
            if enemy==nil then return nil,problem end
            if enemy==value.enemy then
                local fighting,combatWhy=combatFilter(value,cache,unit)
                if fighting==nil then return nil,combatWhy end
                if fighting then
                    local member,why=rangeMember(cache,unit,value.distance)
                    if member==nil then return nil,why end
                    if member then count=count+1 end
                end
            end
        end
    end
    return Functions.values.compare(value.operator, count, value.value)

Назад: Справочник функций