Reference › Function reference › Conditions

Conditions.spatial.nameplateDistanceCount

dependency

Call as

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

Record the dependency Conditions.spatial.nameplateDistanceCount, then call it by that name. A namespaced call does not pass self: use a colon call or pass the object yourself.

What it does

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.

Arguments

NameTypeWhat it does
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.

Returns

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.

Editions

Built In helpers are registered on every edition. What differs is the game API they read; where one is missing the helper falls back or returns nil with a reason.

  • Not available on that edition (the reason is in the tooltip)
  • Only while Blizzard's deprecation fallbacks are on
Game APIClassic EraTBC AnniversaryClassic progressionForeverRetail
UnitExistsClassic EraTBC AnniversaryClassic progressionForeverRetail
UnitIsEnemyClassic EraTBC AnniversaryClassic progressionForeverRetail

Secret values (Retail and Forever)

On Retail and Forever the game hands addons secret values. This helper checks what it reads (addon.Platform:CanReadValue) and returns nil with a reason such as restricted-value instead of a secret it cannot compare. Treat nil as unavailable, not as false.

How the addon calls it

  • Distance Count (evaluate)
    if plates~=nil then return nameplateDistanceCount(value,cache,plates) end

Dependencies

Source

Conditions/spatial.lua, line 690. Read only in game; Duplicate makes an editable copy.

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)

Back to Function reference