at /druid/system/druid_instance.lua
The Druid Factory used to create components
- create_druid_instance
- new
- final
- remove
- update
- on_input
- on_message
- on_window_event
- set_whitelist
- set_blacklist
- new_widget
- new_button
- new_blocker
- new_back_handler
- new_hover
- new_text
- new_grid
- new_scroll
- new_drag
- new_swipe
- new_lang_text
- new_slider
- new_input
- new_data_list
- new_timer
- new_progress
- new_layout
- new_container
- new_hotkey
- new_rich_text
- new_rich_input
instance.create_druid_instance(context, [style])Druid class constructor which used to create Druid components
-
Parameters:
context(table): Druid context. Usually it is self of gui script[style](table?): Druid style table
-
Returns:
instance(druid.instance): The new Druid instance
instance:new(component, ...)Create new Druid component instance
-
Parameters:
component(<T:druid.component>): The component class to create...(...): vararg
-
Returns:
instance(<T:druid.component>): The new ready to use component
instance:final()Call this in gui_script final function.
instance:remove(component)Remove created component from Druid instance.
Component on_remove function will be invoked, if exist.
-
Parameters:
component(<T:druid.component>): Component instance
-
Returns:
is_removed(boolean): True if component was removed
instance:update(dt)Call this in gui_script update function.
- Parameters:
dt(number): Delta time
instance:on_input(action_id, action)Call this in gui_script on_input function.
-
Parameters:
action_id(hash): Action_id from on_inputaction(table): Action from on_input
-
Returns:
is_input_consumed(boolean): The boolean value is input was consumed
instance:on_message(message_id, message, sender)Call this in gui_script on_message function.
- Parameters:
message_id(hash): Message_id from on_messagemessage(table): Message from on_messagesender(url): Sender from on_message
instance:on_window_event(window_event)Called when the window event occurs
- Parameters:
window_event(number): The window event
instance:set_whitelist([whitelist_components])Set whitelist components for input processing. If whitelist is set, only the listed components and their descendants receive input. An empty list allows none. Pass nil to clear the whitelist (all components receive input). Descendants created later still match, no need to call this again.
The filter is scoped to the caller: on the druid instance it affects all components,
on the self.druid inside a component it affects this component subtree only.
The filter owner is not affected by its own filter, so a widget can restrict its children
and keep its own on_input working.
-
Parameters:
[whitelist_components](table|druid.component[]|nil): The array of component to whitelist, nil to clear it
-
Returns:
self(druid.instance): The Druid instance
instance:set_blacklist([blacklist_components])Set blacklist components for input processing. If blacklist is set, the listed components and their descendants are skipped on the input step. An empty list and nil both deny nobody. Descendants created later still match.
The filter is scoped to the caller: on the druid instance it affects all components,
on the self.druid inside a component it affects this component subtree only.
The filter owner is not affected by its own filter, to filter a widget itself
set the filter from the outside: the gui script or the parent widget.
-
Parameters:
[blacklist_components](table|druid.component[]|nil): The array of component to blacklist, nil to clear it
-
Returns:
self(druid.instance): The Druid instance
instance:new_widget(widget, [template], [nodes], ...)Create new Druid widget instance
-
Parameters:
widget(<T:druid.component>): The widget class to create[template](string|nil): The template name used by widget[nodes](string|node|table<hash, node>|nil): The nodes table from gui.clone_tree or prefab node to use for clone or node id to clone...(...): vararg
-
Returns:
widget(<T:druid.component>): The new ready to use widget
instance:new_button(node, [callback], [params], [anim_node])Create Button component
-
Parameters:
node(string|node): The node_id or gui.get_node(node_id)[callback](function|event|nil): Button callback[params](any): Button callback params[anim_node](string|node|nil): Button anim node (node, if not provided)
-
Returns:
button(druid.button): The new button component
instance:new_blocker(node)Create Blocker component
-
Parameters:
node(string|node): The node_id or gui.get_node(node_id)
-
Returns:
blocker(druid.blocker): The new blocker component
instance:new_back_handler([callback], [params])Create BackHandler component
-
Parameters:
[callback](function|event|nil): The callback(self, custom_args) to call on back event[params](any): Callback argument
-
Returns:
back_handler(druid.back_handler): The new back handler component
instance:new_hover(node, [on_hover_callback], [on_mouse_hover_callback])Create Hover component
-
Parameters:
node(string|node): The node_id or gui.get_node(node_id)[on_hover_callback](function|nil): Hover callback[on_mouse_hover_callback](function|nil): Mouse hover callback
-
Returns:
hover(druid.hover): The new hover component
instance:new_text(node, [value], [adjust_type])Create Text component
-
Parameters:
node(string|druid.text|node): The node_id or gui.get_node(node_id)[value](string|nil): Initial text. Default value is node text from GUI scene.[adjust_type](string|nil): Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference
-
Returns:
text(druid.text): The new text component
instance:new_grid(parent_node, item, [in_row])Create Grid component
-
Parameters:
parent_node(string|node): The node_id or gui.get_node(node_id). Parent of all Grid items.item(string|node): Item prefab. Required to get grid's item size. Can be adjusted separately.[in_row](number|nil): How many nodes can be placed in a row
-
Returns:
grid(druid.grid): The new grid component
instance:new_scroll(view_node, content_node)Create Scroll component
-
Parameters:
view_node(string|node): The node_id or gui.get_node(node_id). Will be used as user input node.content_node(string|node): The node_id or gui.get_node(node_id). Will be used as scrollable node inside view_node.
-
Returns:
scroll(druid.scroll): The new scroll component
instance:new_drag(node, [on_drag_callback])Create Drag component
-
Parameters:
node(string|node): The node_id or gui.get_node(node_id). Will be used as user input node.[on_drag_callback](function|nil): Callback for on_drag_event(self, dx, dy)
-
Returns:
drag(druid.drag): The new drag component
instance:new_swipe(node, [on_swipe_callback])Create Swipe component
-
Parameters:
node(string|node): The node_id or gui.get_node(node_id). Will be used as user input node.[on_swipe_callback](function|nil): Swipe callback for on_swipe_end event
-
Returns:
swipe(druid.swipe): The new swipe component
instance:new_lang_text(node, [locale_id], [adjust_type])Create LangText component
-
Parameters:
node(string|node): The node_id or gui.get_node(node_id)[locale_id](string|nil): Default locale id or text from node as default[adjust_type](string|nil): Adjust type for text node. Default: "downscale"
-
Returns:
lang_text(druid.lang_text): The new lang text component
instance:new_slider(pin_node, end_pos, [callback])Create Slider component
-
Parameters:
pin_node(string|node): The node_id or gui.get_node(node_id).end_pos(vector3): The end position of slider[callback](function|nil): On slider change callback
-
Returns:
slider(druid.slider): The new slider component
instance:new_input(click_node, text_node, [keyboard_type])Create Input component
-
Parameters:
click_node(string|node): Button node to enable input componenttext_node(string|druid.text|node): Text node that will be changed on user input[keyboard_type](number|nil): Gui keyboard type for input field
-
Returns:
input(druid.input): The new input component
instance:new_data_list(druid_scroll, druid_grid, create_function)Create DataList component
-
Parameters:
druid_scroll(druid.scroll): The Scroll instance for Data List componentdruid_grid(druid.grid): The Grid instance for Data List componentcreate_function(function): The create function callback(self, data, index, data_list). Function should return (node, [component])
-
Returns:
data_list(druid.data_list): The new data list component
instance:new_timer(node, [seconds_from], [seconds_to], [callback])Create Timer component
-
Parameters:
node(string|node): Gui text node[seconds_from](number|nil): Start timer value in seconds[seconds_to](number|nil): End timer value in seconds[callback](function|nil): Function on timer end
-
Returns:
timer(druid.timer): The new timer component
instance:new_progress(node, key, [init_value])Create Progress component
-
Parameters:
node(string|node): Progress bar fill node or node namekey(string): Progress bar direction: "x" or "y"[init_value](number|nil): Initial value of progress bar. Default: 1
-
Returns:
progress(druid.progress): The new progress component
instance:new_layout(node, [mode])Create Layout component
-
Parameters:
node(string|node): The node_id or gui.get_node(node_id).[mode](string|nil): vertical|horizontal|horizontal_wrap. Default: horizontal
-
Returns:
layout(druid.layout): The new layout component
instance:new_container(node, [mode], [callback])Create Container component
mode:
| "stretch"
| "fit"
| "stretch_x"
| "stretch_y"-
Parameters:
node(string|node): The node_id or gui.get_node(node_id).[mode]("fit"|"stretch"|"stretch_x"|"stretch_y"|nil): Layout mode. Default Fit or Stretch depends from node adjust mode from GUI scene[callback](fun(self: druid.container, size: vector3)|nil): Callback on size changed
-
Returns:
container(druid.container): The new container component
instance:new_hotkey(keys_array, [callback], [callback_argument])Create Hotkey component
-
Parameters:
keys_array(string|string[]): Keys for trigger action. Should contains one action key and any amount of modificator keys[callback](function|event|nil): The callback function[callback_argument](any): The argument to pass into the callback function
-
Returns:
hotkey(druid.hotkey): The new hotkey component
instance:new_rich_text(text_node, [value])Create RichText component.
-
Parameters:
text_node(string|node): The text node to make Rich Text[value](string|nil): The initial text value. Default will be gui.get_text(text_node)
-
Returns:
rich_text(druid.rich_text): The new rich text component
instance:new_rich_input(template, [nodes])Create RichInput component. As a template please check rich_input.gui layout.
-
Parameters:
template(string): The template string name[nodes](table|nil): Nodes table from gui.clone_tree
-
Returns:
rich_input(druid.rich_input): The new rich input component