Reference › Function reference › Core

Core.point_conditions.pointIdentity

dependency

Call as

Core.point_conditions.pointIdentity(self, unit, key)

Record the dependency Core.point_conditions.pointIdentity, 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

Observes whether unit exists and, if so, its class, for the point-resource selectors. For the player it reuses a class stored in self.longtermCache under key when it was recorded against the same UnitClass function, and otherwise stores the freshly read class there.

Arguments

NameTypeWhat it does
selfRMAddonRotation Master addon instance.
unitstringUnit token to observe.
keyanyLong-term cache key for the player's class; only used for "player". The addon passes a private table.

Returns

1table | nil{exists=false}, or {exists=true, class=token}; nil when unavailable.
2string | nilThe platform observer's reason for nil.

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
UnitClassClassic 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.

Example

-- needs the dependency Core.point_conditions.pointIdentity
local record, reason = Functions.cache.getCached(cache, Core.point_conditions.pointIdentity, addon, "target")
if not record then return nil, reason end
return record.exists and record.class == "ROGUE"

Source

Core/point_conditions.lua, line 27. Read only in game; Duplicate makes an editable copy.

Core.point_conditions.pointIdentity(self, unit, key)
    local platform=self.Platform
    local nativeClass=UnitClass
    local longterm=self.longtermCache
    if not platform:CanReadValue(longterm) or type(longterm)~='table' then longterm=nil end
    local class
    if unit=='player' and longterm and platform:CanReadValue(nativeClass) and type(nativeClass)=='function' then
        local entry=rawget(longterm,key)
        if platform:CanReadValue(entry) and type(entry)=='table' then
            local api,candidate=rawget(entry,'api'),rawget(entry,'class')
            if platform:CanReadValue(api) and api==nativeClass and platform:CanReadValue(candidate) and type(candidate)=='string' and candidate~='' then class=candidate end
        end
    end
    local record,reason=platform:GetUnitPointIdentityObservation(unit,class==nil)
    if not record then return nil,reason end
    if not record.exists then return record end
    if class then record.class=class
    elseif unit=='player' and longterm and type(nativeClass)=='function' and nativeClass==UnitClass then
        rawset(longterm,key,{api=nativeClass,class=record.class})
    end
    return record

Back to Function reference