Referência › Referência de funções › Conditions

Conditions.spatial.nameplateDistanceCount

dependência

Chame como

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

Registre a dependência Conditions.spatial.nameplateDistanceCount e depois chame-a por esse nome. Uma chamada com namespace não passa self: use uma chamada com dois-pontos ou passe o objeto você mesmo.

O que faz

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.

Argumentos

NomeTipoO que faz
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.

Retornos

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.

Edições

As funções auxiliares integradas são registradas em todas as edições. O que muda é a API do jogo que elas leem; quando uma está ausente, a função auxiliar recorre a uma alternativa ou retorna nil com um motivo.

  • Indisponível nessa edição (o motivo está na dica)
  • Só enquanto as alternativas da Blizzard para APIs obsoletas estiverem ativas
API do jogoClassic EraTBC AnniversaryClassic ProgressionForeverRetail
UnitExistsClassic EraTBC AnniversaryClassic ProgressionForeverRetail
UnitIsEnemyClassic EraTBC AnniversaryClassic ProgressionForeverRetail

Valores secretos (Retail e Forever)

No Retail e no Forever, o jogo entrega valores secretos aos addons. Esta função auxiliar verifica o que lê (addon.Platform:CanReadValue) e retorna nil com um motivo como restricted-value em vez de um valor secreto que não consegue comparar. Trate nil como indisponível, não como false.

Como o addon a chama

Dependências

Código-fonte

Conditions/spatial.lua, linha 690. Somente leitura no jogo; Duplicar cria uma cópia editável.

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)

Voltar para Referência de funções