Actions

Methods
6
Fields
None

Methods

MethodReturnsDescription
isBusy()booleanWhether any action the calling plugin queued has neither gone out nor been dropped. Each plugin sees only its own actions.
droppedLastTick()numberHow many of the calling plugin's actions the scheduler dropped during the previous tick: past the plugin's setMaxPerTick cap, not out by…
refusedCount()numberHow many of the calling plugin's actions were refused when they went out on this client: queued (true), planned and sent to the virtual m…
lastRefusal()string?Why the calling plugin's most recent refused action was refused, then the action, as the client log says it (`"'Take' is not a ground optio…
sameTick()()Every action the plugin queues from now until the queue is next drained (this tick's plan, or, outside GameTick, the next client cycle) i…
setMaxPerTick(number?)()For the calling plugin only: at most count of the plugin's actions go into one tick's plan, the first queued, and the rest are dropped, c…

Method details

isBusy

isBusy: () -> boolean

Whether any action the calling plugin queued has neither gone out nor been dropped. Each plugin sees only its own actions.

Example
function plugin:onGameTick(_event: GameTick)
    -- Something this plugin queued has not gone out yet: queue nothing more.
    -- It does not show whether the last action worked; only game state does.
    if Actions.isBusy() then
        return
    end
    if player:currentHitpoints() < 20 then
        player:inventory():interact(FOOD, "Eat")
    end
end

droppedLastTick

droppedLastTick: () -> number

How many of the calling plugin's actions the scheduler dropped during the previous tick: past the plugin's setMaxPerTick cap, not out by that tick's deadline (nothing is refused when queued: what the tick cannot send is dropped), still unfired when its tick ended, held back past the deadline or left unresolved by the virtual mouse, turned away before its press, or cleared while logged out; none is kept for a later tick. Read it in onGameTick to know whether any of last tick's actions were dropped.

refusedCount

refusedCount: () -> number

How many of the calling plugin's actions were refused when they went out on this client: queued (true), planned and sent to the virtual mouse, then turned down before any click, as an option the target does not offer, a target gone by then or a widget not there. It only rises, so a count higher than last read means a new refusal; Actions.lastRefusal() says why. Not counted: actions dropped (droppedLastTick), and clicks the game itself turns down.

lastRefusal

lastRefusal: () -> string?

Why the calling plugin's most recent refused action was refused, then the action, as the client log says it ("'Take' is not a ground option on 'Bones': ..."); nil when none has been. Read it when Actions.refusedCount() rises, so a click that can never go out is not queued again and again.

sameTick

sameTick: () -> ()

Every action the plugin queues from now until the queue is next drained (this tick's plan, or, outside GameTick, the next client cycle) is admitted to one tick together, in the order queued, or not at all. An equip, an eat and a prayer never split across ticks, a prayer flick (its own two-press unit) and a use-on included: a unit queued inside this one joins it. An action made of two clicks (a use-on's select and its target, a cast's spell and its target) is one same-tick unit by itself.

setMaxPerTick

setMaxPerTick: (number?) -> ()

For the calling plugin only: at most count of the plugin's actions go into one tick's plan, the first queued, and the rest are dropped, counted in Actions.droppedLastTick(); none is kept for a later tick. Without a cap (nil clears it, the default) a tick's plan takes everything queued and sends what goes out by its deadline: the scheduler caps nothing by count, only this does. Once one of the plugin's actions is dropped, every later one of that tick is too, so none goes out ahead of one queued before it. Any count from 1 is taken (0 is 1), and a same-tick unit larger than the cap goes out whole as the plugin's first of a tick. An action the last tick left unfired goes first and counts against the cap. An action queued outside GameTick is not planned, so not counted.