Module DruidInstance

Instance of Druid.

Make one instance per gui_script with next code:

local druid = require("druid.druid") function init(self) self.druid = druid.new(self) local button = self.druid:new_button(...) end

Learn Druid instance function here

See also:

Functions

final(self) Call on final function on gui_script.
log_message(self, message[, context]) Log message, if is_debug mode is enabled
new(self, component, ...) Create new druid component
new_back_handler(self, callback[, params]) Create back_handler basic component
new_blocker(self, node) Create blocker basic component
new_button(self, node, callback[, params[, anim_node]]) Create button basic component
new_checkbox(self, node, callback[, click_node=node[, initial_state=false]]) Create checkbox component
new_checkbox_group(self, nodes, callback[, click_nodes=node]) Create checkbox_group component
new_data_list(self, druid_scroll, druid_grid, create_function) Create data list basic component
new_drag(self, node, on_drag_callback) Create drag basic component
new_dynamic_grid(self, parent) Create dynamic grid component
new_grid(self, parent, element[, in_row=1]) Create grid basic component Deprecated
new_hover(self, node, on_hover_callback) Create hover basic component
new_input(self, click_node, text_node[, keyboard_type]) Create input component
new_lang_text(self, node, locale_id, no_adjust) Create lang_text component
new_progress(self, node, key[, init_value=1]) Create progress component
new_radio_group(self, nodes, callback[, click_nodes=node]) Create radio_group component
new_scroll(self, view_node, content_node) Create scroll basic component
new_slider(self, node, end_pos[, callback]) Create slider component
new_static_grid(self, parent, element[, in_row=1]) Create static grid basic component
new_swipe(self, node, on_swipe_callback) Create swipe basic component
new_text(self, node[, value[, no_adjust]]) Create text basic component
new_timer(self, node, seconds_from[, seconds_to=0[, callback]]) Create timer component
on_input(self, action_id, action) Druid on_input function
on_message(self, message_id, message, sender) Druid on_message function
remove(self, component) Remove component from druid instance.
set_blacklist(self[, blacklist_components=nil]) Set blacklist components for input processing.
set_debug(self, is_debug) Set debug mode for current Druid instance.
set_whitelist(self[, whitelist_components=nil]) Set whitelist components for input processing.
update(self, dt) Druid update function


Functions

final(self)
Call on final function on gui_script. It will call on_remove on all druid components

Parameters:

  • self DruidInstance
log_message(self, message[, context])
Log message, if is_debug mode is enabled

Parameters:

new(self, component, ...)
Create new druid component

Parameters:

  • self DruidInstance
  • component Component Component module
  • ... args Other component params to pass it to component:init function
new_back_handler(self, callback[, params])
Create back_handler basic component

Parameters:

  • self DruidInstance
  • callback callback On back button
  • params any Callback argument (optional)

Returns:

    BackHandler back_handler component
new_blocker(self, node)
Create blocker basic component

Parameters:

  • self DruidInstance
  • node node Gui node

Returns:

    Blocker blocker component
new_button(self, node, callback[, params[, anim_node]])
Create button basic component

Parameters:

  • self DruidInstance
  • node node Gui node
  • callback function Button callback
  • params table Button callback params (optional)
  • anim_node node Button anim node (node, if not provided) (optional)

Returns:

    Button button component
new_checkbox(self, node, callback[, click_node=node[, initial_state=false]])
Create checkbox component

Parameters:

  • self DruidInstance
  • node node Gui node
  • callback function Checkbox callback
  • click_node node Trigger node, by default equals to node (default node)
  • initial_state boolean The initial state of checkbox, default - false (default false)

Returns:

    Checkbox checkbox component
new_checkbox_group(self, nodes, callback[, click_nodes=node])
Create checkbox_group component

Parameters:

  • self DruidInstance
  • nodes node[] Array of gui node
  • callback function Checkbox callback
  • click_nodes node[] Array of trigger nodes, by default equals to nodes (default node)

Returns:

    CheckboxGroup checkbox_group component
new_data_list(self, druid_scroll, druid_grid, create_function)
Create data list basic component

Parameters:

  • self DruidInstance
  • druid_scroll Scroll The Scroll instance for Data List component
  • druid_grid Grid The Grid instance for Data List component
  • create_function function The create function callback(self, data, index, data_list). Function should return (node, [component])

Returns:

    DataList data_list component
new_drag(self, node, on_drag_callback)
Create drag basic component

Parameters:

  • self DruidInstance
  • node node GUI node to detect dragging
  • on_drag_callback function Callback for on_drag_event(self, dx, dy)

Returns:

    Drag drag component
new_dynamic_grid(self, parent)
Create dynamic grid component

Parameters:

  • self DruidInstance
  • parent node The gui node parent, where items will be placed

Returns:

    DynamicGrid grid component
new_grid(self, parent, element[, in_row=1])
Create grid basic component Deprecated

Parameters:

  • self DruidInstance
  • parent node The gui node parent, where items will be placed
  • element node Element prefab. Need to get it size
  • in_row number How many nodes in row can be placed (default 1)

Returns:

    StaticGrid grid component
new_hover(self, node, on_hover_callback)
Create hover basic component

Parameters:

  • self DruidInstance
  • node node Gui node
  • on_hover_callback function Hover callback

Returns:

    Hover hover component
new_input(self, click_node, text_node[, keyboard_type])
Create input component

Parameters:

  • self DruidInstance
  • click_node node Button node to enabled input component
  • text_node node Text node what will be changed on user input
  • keyboard_type number Gui keyboard type for input field (optional)

Returns:

    Input input component
new_lang_text(self, node, locale_id, no_adjust)
Create lang_text component

Parameters:

  • self DruidInstance
  • node node The text node
  • locale_id string Default locale id
  • no_adjust bool If true, will not correct text size

Returns:

    LangText lang_text component
new_progress(self, node, key[, init_value=1])
Create progress component

Parameters:

  • self DruidInstance
  • node string or node Progress bar fill node or node name
  • key string Progress bar direction: const.SIDE.X or const.SIDE.Y
  • init_value number Initial value of progress bar (default 1)

Returns:

    Progress progress component
new_radio_group(self, nodes, callback[, click_nodes=node])
Create radio_group component

Parameters:

  • self DruidInstance
  • nodes node[] Array of gui node
  • callback function Radio callback
  • click_nodes node[] Array of trigger nodes, by default equals to nodes (default node)

Returns:

    RadioGroup radio_group component
new_scroll(self, view_node, content_node)
Create scroll basic component

Parameters:

  • self DruidInstance
  • view_node node GUI view scroll node
  • content_node node GUI content scroll node

Returns:

    Scroll scroll component
new_slider(self, node, end_pos[, callback])
Create slider component

Parameters:

  • self DruidInstance
  • node node Gui pin node
  • end_pos vector3 The end position of slider
  • callback function On slider change callback (optional)

Returns:

    Slider slider component
new_static_grid(self, parent, element[, in_row=1])
Create static grid basic component

Parameters:

  • self DruidInstance
  • parent node The gui node parent, where items will be placed
  • element node Element prefab. Need to get it size
  • in_row number How many nodes in row can be placed (default 1)

Returns:

    StaticGrid grid component
new_swipe(self, node, on_swipe_callback)
Create swipe basic component

Parameters:

  • self DruidInstance
  • node node Gui node
  • on_swipe_callback function Swipe callback for on_swipe_end event

Returns:

    Swipe swipe component
new_text(self, node[, value[, no_adjust]])
Create text basic component

Parameters:

  • self DruidInstance
  • node node Gui text node
  • value string Initial text. Default value is node text from GUI scene. (optional)
  • no_adjust bool If true, text will be not auto-adjust size (optional)

Returns:

    Tet text component
new_timer(self, node, seconds_from[, seconds_to=0[, callback]])
Create timer component

Parameters:

  • self DruidInstance
  • node node Gui text node
  • seconds_from number Start timer value in seconds
  • seconds_to number End timer value in seconds (default 0)
  • callback function Function on timer end (optional)

Returns:

    Timer timer component
on_input(self, action_id, action)
Druid on_input function

Parameters:

  • self DruidInstance
  • action_id hash Action_id from on_input
  • action table Action from on_input

Returns:

    bool The boolean value is input was consumed
on_message(self, message_id, message, sender)
Druid on_message function

Parameters:

  • self DruidInstance
  • message_id hash Message_id from on_message
  • message table Message from on_message
  • sender hash Sender from on_message
remove(self, component)
Remove component from druid instance. Component `on_remove` function will be invoked, if exist.

Parameters:

  • self DruidInstance
  • component Component Component instance
set_blacklist(self[, blacklist_components=nil])
Set blacklist components for input processing. If blacklist is not empty and component contains in this list, component will be not processed on input step

Parameters:

  • self DruidInstance DruidInstance
  • blacklist_components table or Component The array of component to blacklist (default nil)
set_debug(self, is_debug)
Set debug mode for current Druid instance. It's enable debug log messages

Parameters:

Returns:

    self DruidInstance
set_whitelist(self[, whitelist_components=nil])
Set whitelist components for input processing. If whitelist is not empty and component not contains in this list, component will be not processed on input step

Parameters:

  • self DruidInstance
  • whitelist_components table or Component The array of component to whitelist (default nil)
update(self, dt)
Druid update function

Parameters:

  • self DruidInstance
  • dt number Delta time
generated by LDoc 1.4.6 Last updated 2022-03-11 20:55:29