The conditions editor (fl_conditions): a tree in which every node is a condition. The nodes on one level are alternatives, and a node with nodes under it also needs one of those to hold. Right-clicking a node adds a condition under it, sets its parameter or operator, or deletes it. The tree is read with get_conditions and filled with set_conditions, and it can be saved to and loaded from named presets.

Summary

Methods

Adds a node of the specified condition type under the parent node.
clear()client
Removes all condition nodes from the tree, leaving only the root node.
Opens a selector popup and calls the callback once for every choice right away, so that it can add the choice to the selector.
Collects the condition tree into a table that can be networked, saved and passed to Conditions:check.
Init()client
Creates the root node of the condition tree and the buttons that save and load condition presets.
Opens the context menu of a node: adding a child condition and, for condition nodes, setting the parameter and the operator or deleting the condition.
Recreates the nodes of a condition tree under the parent node.
update()client
Moves the save and load buttons to the top right corner of the panel.

Methods

PANEL:add_condition(parent, id, data)

client plugins/conditions/plugin/views/cl_conditions.lua:152

Adds a node of the specified condition type under the parent node.

Parameters

  • parent Panel tree node to add the condition to
  • id String id of a registered condition
  • data Map optional, defaults to nil parameters of the condition, empty when omitted

Returns

  • Panel the created node

Removes all condition nodes from the tree, leaving only the root node.

PANEL:create_selector(title, message, default_value, choices, callback)

client plugins/conditions/plugin/views/cl_conditions.lua:261

Opens a selector popup and calls the callback once for every choice right away, so that it can add the choice to the selector.

parent:create_selector(data.name, 'condition.role.message', 'condition.roles',
  Bolt:get_roles(), function(selector, role)
    selector:add_choice(t(role.name), function()
      panel.data.role = role.id

      panel.update()
    end)
  end)

Parameters

  • title String title phrase
  • message String message phrase
  • default_value String phrase of the text that is displayed before a choice is made
  • choices List/Map values to choose from
  • callback Function called as callback(selector, choice) for every choice

Returns

  • Panel the created fl_selector panel

PANEL:get_conditions(panel)

client plugins/conditions/plugin/views/cl_conditions.lua:190

Collects the condition tree into a table that can be networked, saved and passed to Conditions:check.

Parameters

  • panel Panel optional, defaults to nil node to start from, the root node when omitted

Returns

  • List condition nodes, each a Map with id, data and childs

Creates the root node of the condition tree and the buttons that save and load condition presets.

PANEL:node_options(panel, _root, _first)

client plugins/conditions/plugin/views/cl_conditions.lua:94

Opens the context menu of a node: adding a child condition and, for condition nodes, setting the parameter and the operator or deleting the condition.

Parameters

  • panel Panel the tree node that was right-clicked
  • _root Boolean optional, defaults to nil whether the node is the root node, unused
  • _first Boolean optional, defaults to nil whether the node has no child conditions, unused

PANEL:set_conditions(parent, conditions)

client plugins/conditions/plugin/views/cl_conditions.lua:218

Recreates the nodes of a condition tree under the parent node. Nodes whose condition type is not registered are left out, together with their child nodes.

Parameters

  • parent Panel tree node to add the conditions to, e.g. the root node
  • conditions List condition nodes as returned by get_conditions; nothing is added when it is not a table

Moves the save and load buttons to the top right corner of the panel. Should be called after the panel has been resized.

Defined in