Core Module - Gui - Used to define new gui elements and gui event handlers
-- Defining a button that prints the player's name
local example_button =
Gui.new_element{
type = 'button',
caption = 'Example Button'
}
:on_click(function(event)
local player = event.player
player.print(player.name)
end)
-- Defining using a custom function
local example_flow_with_button =
Gui.new_element(function(event_trigger,parent)
local flow =
parent.add{
name = 'example_flow',
type = 'flow'
}
local element =
flow.add{
name = event_trigger,
type = 'button',
caption = 'Example Button'
}
return element
end)
:on_click(function(event)
local player = event.player
player.print(player.name)
end)
-- Drawing an element
local exmple_button_element = example_button(parent)
local example_flow_with_button = example_flow_with_button(parent)
| utils.event |
| mod-gui |
| top_elements | Contains the uids of the elements that will show on the top flow and the auth function |
| left_elements | Contains the uids of the elements that will show on the left flow and the open on join function |
| defines | Table of all the elements which have been registed with the draw function and event handlers |
| file_paths | An index used for debuging to find the file where different elements where registered |
| _prototype_element | The element prototype which is returned from Gui.new_element |
| _mt_element | The prototype metatable applied to new element defines |
| uid | The current highest uid that is being used, will not increase during runtime |
| new_element(element_define) | Base function used to define new elements, can be used with a table or with a function |
| Gui._prototype_element:add_to_top_flow([authenticator]) | Adds an element to be drawn to the top flow when a player joins |
| Gui._prototype_element:add_to_left_flow([open_on_join]) | Adds an element to be drawn to the left flow when a player joins |
| Gui._prototype_element.on_opened | Called when the player opens a GUI. |
| Gui._prototype_element.on_closed | Called when the player closes the GUI they have open. |
| Gui._prototype_element.on_click | Called when LuaGuiElement is clicked. |
| Gui._prototype_element.on_confirmed | Called when a LuaGuiElement is confirmed, for example by pressing Enter in a textfield. |
| Gui._prototype_element.on_checked_changed | Called when LuaGuiElement checked state is changed (related to checkboxes and radio buttons). |
| Gui._prototype_element.on_elem_changed | Called when LuaGuiElement element value is changed (related to choose element buttons). |
| Gui._prototype_element.on_location_changed | Called when LuaGuiElement element location is changed (related to frames in player.gui.screen). |
| Gui._prototype_element.on_tab_changed | Called when LuaGuiElement selected tab is changed (related to tabbed-panes). |
| Gui._prototype_element.on_selection_changed | Called when LuaGuiElement selection state is changed (related to drop-downs and listboxes). |
| Gui._prototype_element.on_switch_changed | Called when LuaGuiElement switch state is changed (related to switches). |
| Gui._prototype_element.on_text_change | Called when LuaGuiElement text is changed by the player. |
| Gui._prototype_element.on_value_changed | Called when LuaGuiElement slider value is changed (related to the slider element). |
| toggle_top_flow | Button which toggles the top flow elements |
| get_top_flow(player) | Gets the flow which contains the elements for the top flow |
| update_top_flow(player) | Updates the visible states of all the elements on a players top flow |
| toggle_top_flow(player[, state]) | Toggles the visible states of all the elements on a players top flow |
| hide_left_flow | Button which hides the elements in the left flow |
| get_left_flow(player) | Gets the flow which contains the elements for the left flow |
| hide_left_flow(player) | Hides all left elements for a player |
| toggle_left_element(player, element_define[, state]) | Toggles the visible state of all a left element for a player |
Contains the uids of the elements that will show on the top flow and the auth function
Contains the uids of the elements that will show on the left flow and the open on join function
Table of all the elements which have been registed with the draw function and event handlers
An index used for debuging to find the file where different elements where registered
The element prototype which is returned from Gui.new_element
The prototype metatable applied to new element defines
Fields:The current highest uid that is being used, will not increase during runtime
Base function used to define new elements, can be used with a table or with a function
Parameters:-- Defining an element with a table
local example_button =
Gui.new_element{
type = 'button',
caption = 'Example Button'
}
-- Defining an element with a function
local example_flow_with_button =
Gui.new_element(function(event_trigger,parent)
local flow =
parent.add{
name = 'example_flow',
type = 'flow'
}
local element =
flow.add{
name = event_trigger,
type = 'button',
caption = 'Example Button'
}
return element
end)
Adds an element to be drawn to the top flow when a player joins
Parameters:-- Adding the example button
example_button:add_to_top_flow(function(player)
-- example button will only show when game time is less than 1 minute
return player.online_time < 3600
end)
Adds an element to be drawn to the left flow when a player joins
Parameters:-- Adding the example button
example_flow_with_button:add_to_left_flow(true)
Called when the player opens a GUI.
Called when the player closes the GUI they have open.
Called when LuaGuiElement is clicked.
Called when a LuaGuiElement is confirmed, for example by pressing Enter in a textfield.
Called when LuaGuiElement checked state is changed (related to checkboxes and radio buttons).
Called when LuaGuiElement element value is changed (related to choose element buttons).
Called when LuaGuiElement element location is changed (related to frames in player.gui.screen).
Called when LuaGuiElement selected tab is changed (related to tabbed-panes).
Called when LuaGuiElement selection state is changed (related to drop-downs and listboxes).
Called when LuaGuiElement switch state is changed (related to switches).
Called when LuaGuiElement text is changed by the player.
Called when LuaGuiElement slider value is changed (related to the slider element).
Button which toggles the top flow elements
Gets the flow which contains the elements for the top flow
(player)
Parameters:-- Geting your top element flow
local top_flow = Gui.get_top_flow(game.player)
Updates the visible states of all the elements on a players top flow
Parameters:-- Update your flow
Gui.update_top_flow(game.player)
Toggles the visible states of all the elements on a players top flow
Parameters:-- Toggle your flow
Gui.toggle_top_flow(game.player)
-- Open your top flow
Gui.toggle_top_flow(game.player,true)
Button which hides the elements in the left flow
Gets the flow which contains the elements for the left flow
(player)
Parameters:-- Geting your left element flow
local left_flow = Gui.get_left_flow(game.player)
Hides all left elements for a player
Parameters:-- Hide your left elements
Gui.hide_left_flow(game.player)
Toggles the visible state of all a left element for a player
Parameters:-- Toggle your example button
Gui.toggle_top_flow(game.player,example_flow_with_button)
-- Open your example button
Gui.toggle_top_flow(game.player,example_flow_with_button,true)