Reference › Function reference › Platform

Platform.loss_of_control.GetLossOfControlEvent

public

Call as

addon.Platform:GetLossOfControlEvent(index, kind)

Available directly through addon; no dependency is needed.

What it does

Read one documented active loss-of-control row by its native index and requested subject kind. Type queries require only the readable control type string; school queries require only the readable finite nonnegative integer school mask. Optional timing is returned as a finite timeRemaining or an explicit per-field reason, so an unrelated subject does not require a usable timer. Missing rows are unavailable snapshot observations. No display fields, inferred deadline, duration sum, maximum or native alias fallback is used.

Arguments

NameTypeWhat it does
selfRMPlatformRotation Master platform adapter (implicit with colon calls).
indexnumberNative one-based integral active-row index within the 256-row RM scan budget.
kindstringExactly type or school; selects the required subject field without requiring the other.

Returns

1table | nilNormalized requested subject with finite timeRemaining or timeRemainingReason; nil when the required row or subject is unavailable.
2string | nilPolicy, query, capability or required row/subject availability reason for a nil record.

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
C_LossOfControlClassic EraTBC AnniversaryClassic progressionForeverRetail
canaccessvalueClassic 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

local count = addon.Platform:GetLossOfControlCount()
if count == nil then return nil end
if count == 0 then return false end
local row = addon.Platform:GetLossOfControlEvent(1, "type")
if not row then return nil end
return row.locType == "STUN"

Source

Platform/loss_of_control.lua, line 45. Read only in game; Duplicate makes an editable copy.

Platform.loss_of_control.GetLossOfControlEvent(self, index, kind)
    local policy=self:GetCombatDataPolicy()
    if policy~='probe' and policy~='restricted' then return nil,'unsupported-policy' end
    if not self:CanReadValue(index) or not self:CanReadValue(kind) then return nil,'restricted-value' end
    if canaccessvalue and not canaccessvalue(index) then return nil,'restricted-value' end
    if type(index)~='number' or index~=index or index==math.huge or index==-math.huge or index<1 or index%1~=0 then return nil,'invalid-loss-of-control-query' end
    if kind~='type' and kind~='school' then return nil,'invalid-loss-of-control-query' end
    if index>256 then return nil,'loss-of-control-budget-exceeded' end
    local namespace=C_LossOfControl
    if not self:CanReadValue(namespace) then return nil,'restricted-value' end
    if type(namespace)~='table' then return nil,'missing-api' end
    local methodOk,method=pcall(function() return namespace.GetActiveLossOfControlData end)
    if not methodOk then return nil,'api-error' end
    if not self:CanReadValue(method) then return nil,'restricted-value' end
    if type(method)~='function' then return nil,'missing-api' end
    local ok,event=pcall(method,index)
    if not ok then return nil,'api-error' end
    if not self:CanReadValue(event) then return nil,'restricted-value' end
    if event==nil then return nil,'loss-of-control-event-unavailable' end
    if type(event)~='table' then return nil,'invalid-api-result' end
    local subjectOk,subject=pcall(function() return event[kind=='type' and 'locType' or 'lockoutSchool'] end)
    if not subjectOk then return nil,'api-error' end
    if not self:CanReadValue(subject) then return nil,'restricted-value' end
    if canaccessvalue and not canaccessvalue(subject) then return nil,'restricted-value' end
    if subject==nil then return nil,'loss-of-control-subject-unavailable' end
    local record={}
    if kind=='type' then
        if type(subject)~='string' then return nil,'invalid-api-result' end
        record.locType=subject
    else
        if type(subject)~='number' or subject~=subject or subject==math.huge or subject==-math.huge or subject<0 or subject%1~=0 then return nil,'invalid-api-result' end
        record.lockoutSchool=subject
    end
    local timeOk,remaining=pcall(function() return event.timeRemaining end)
    if not timeOk then record.timeRemainingReason='api-error'
    elseif not self:CanReadValue(remaining) then record.timeRemainingReason='restricted-value'
    elseif canaccessvalue and not canaccessvalue(remaining) then record.timeRemainingReason='restricted-value'
    elseif remaining==nil then record.timeRemainingReason='loss-of-control-time-unavailable'
    elseif type(remaining)~='number' or remaining~=remaining or remaining==math.huge or remaining==-math.huge then record.timeRemainingReason='invalid-api-result'
    else record.timeRemaining=remaining end
    return record

Back to Function reference