handler

A support class for handler handlers. It is not used directly, rather it is a 'super class' that provides common functionality.

Instances of the class primarily need to provide functions for the following:

local handler = actionManager:addHandler("foobar")
:onChoices(function(choices) ... end)
:onExecute(function(action) ... end)

The choices added to the choices should have the params value set to a table containing the details of the action to execute if the choice is selected.

API Overview

  • Constructors - API calls which return an object, typically one that offers API methods

  • Fields - Variables which can only be accessed from an object returned by a constructor

  • Methods - API calls which can only be made on an object returned by a constructor

API Documentation

Constructors

new

Signature

plugins.core.action.handler.new(id, group) -> handler

Type

Constructor

Description

Creates a new handler with the specified ID.

Parameters

Returns

Fields

cached

Signature

plugins.core.action.handler.cached <cp.prop: boolean>

Type

Field

Description

If set to true (the default), any choices created will be cached until [reset] is called.

choices

Signature

plugins.core.action.handler.choices <cp.prop: cp.choices; read-only>

Type

Field

Description

Provides cp.choices instance for the handler. May be watched/monitored/etc.

Methods

actionId

Signature

plugins.core.action.handler:actionId(action) -> string

Type

Method

Description

Returns a string that can be used as a unique ID for the action details.

execute

Signature

plugins.core.action.handler:execute(action) -> boolean

Type

Method

Description

Executes the action, based on values in the table.

Parameters

Returns

group

Signature

plugins.core.action.handler:group() -> string

Type

Method

Description

Returns the group for this handler.

Parameters

Returns

id

Signature

plugins.core.action.handler:id() -> string

Type

Method

Description

Returns the ID for this handler.

Parameters

Returns

Signature

plugins.core.action.handler:onActionId(actionFn) -> handler

Type

Method

Description

Configures a function to handle converting an action to unique ID.

Parameters

Returns

onChoices

Signature

plugins.core.action.handler:onChoices(choicesFn) -> handler

Type

Method

Description

Adds a callback function which will receive the cp.choices instance to add

Parameters

Returns

onExecute

Signature

plugins.core.action.handler:onExecute(executeFn) -> handler

Type

Method

Description

Configures the function to call when a choice is executed. This will be passed

Parameters

Returns

reset

Signature

plugins.core.action.handler:reset([updateNow]) -> nil

Type

Method

Description

Resets the handler, clearing any cached result and requesting new ones.

Parameters

Returns