Class Game.TextMenu
Game Text Menu class.
Main text menu class.
To builds and displays text menus.
| Game.TextMenu:Create (title) |
Constructs a text menu builder. |
| Game.TextMenu:Get ([configName]) |
Gets the menu configuration(s). |
| Game.TextMenu:Set (configs[, ...]) |
Sets the menu configuration(s). |
| Game.TextMenu:GetSelectableItems () |
Gets all selectable items from this menu. |
| Game.TextMenu:GetItem (index) |
Gets an item from this menu. |
| Game.TextMenu:AddItem (displayText[, userData[, isDisabled=false[, isVisualOnly=false[, pos]]]]) |
Adds an item to this menu. |
| Game.TextMenu:AddText (displayText[, isVisualOnly=false[, pos]]) |
Adds a text line to this menu. |
| Game.TextMenu:AddBlank ([isVisualOnly=false[, pos]]) |
Adds a blank line to this menu. |
| Game.TextMenu:Open ([player=nil[, displayTime=-1[, pageIndex=1]]]) |
Opens this menu. |
| Game.TextMenu:Close (player) |
Closes a player's menu. |
| Game.TextMenu:GetItemCount () |
Gets the number of selectable items in this menu. |
| Game.TextMenu:GetMaxItemPerPage () |
Gets allowed maximum items per page. |
| Game.TextMenu:GetPageCount () |
Gets the number of pages in this menu. |
| Game.TextMenu:ToString () |
Returns the title of this menu. |
-
.textMenuItemProperty
-
The menu item's properties.
- text
string
The display text.
- userdata
anything
A variable for storing arbitrary data.
(default nil)
- isDisabled
boolean
The item has grey color and won't invokes callback.
(default false)
- isVisualOnly
boolean
The item should be a visual shift only (not shifting the slot numbering down).
(default false)
-
.textMenuConfiguration
-
The text menu configuration table.
- itemPerPage
number
Number of items per page (0 = no paginating)(minimum = 1).
(default 7)
- backName
string
Name of the back button.
(default "Back")
- nextName
string
Name of the next button.
(default "More")
- exitName
string
Name of the exit button.
(default "Exit")
- title
string
Menu title text.
(default "New text menu")
- exit
number
Exit mode.
(default Game.TextMenu.EXIT.ALL)
- noColors
boolean
Sets whether colors are not auto-assigned.
(default false)
- numberColor
string
Color indicator to use for slot numbers.
(default "\r")
- pageCallback
boolean
Whether to forward pagination slots to text menu callback.
(default false)
- showPage
boolean
Whether to show the page number in menu title.
(default true)
- extraSlots
boolean
Whether to use slot #8, #9, and #0 for items if possible.
(default false)
-
.textMenuAddOption
-
The
Game.TextMenu:Add* options.
- text
string
The display text.
- userdata
anything
A variable for storing arbitrary data.
(optional)
- position
number
The menu item position.
(optional)
- disabled
boolean
The item has grey color and won't invokes callback.
(default false)
- visualOnly
boolean
The item should be a visual shift only (not shifting the slot numbering down).
(default false)
-
.textMenuOpenOption
-
The Game.TextMenu:Open options.
- player
Game.Player or nil
A player that receive this menu. | All connected players will receive this menu.
(default nil)
- duration
number
If >=0 menu will timeout after this many seconds (maximum = 255 seconds)(-2 = Don't change currently time set).
(default -1)
- page
number
Page to start from (starting from 1).
(default 1)
-
Game.TextMenu.EXIT
-
List of available exit modes.
Fields:
- ALL
Menu will have an exit option (default).
- NEVER
Menu will not have an exit option.
-
Game.TextMenu.CONFIG
-
List of available configurations to set.
Fields:
- ITEM_PER_PAGE
Number of items per page.
- BACK_NAME
Name of the back button.
- NEXT_NAME
Name of the next button.
- EXIT_NAME
Name of the exit button.
- TITLE
Menu title text.
- EXIT
Exit mode.
- NO_COLORS
Sets whether colors are not auto-assigned.
- NUMBER_COLOR
Color indicator to use for slot numbers.
- PAGE_CALLBACK
Whether to forward pagination slots to text menu callback.
- SHOW_PAGE
Whether to show the page number in menu title.
- EXTRA_SLOTS
Whether to use slot #8, #9, and #0 for items if possible.
-
Game.TextMenu.item
-
The menu items.
-
Game.TextMenu:Create (title)
-
Constructs a text menu builder.
Parameters:
- title
string or nil
The menu title to set. Sets to
nil to excludes title.
Returns:
Game.TextMenu
A new text menu builder.
-
Game.TextMenu:Get ([configName])
-
Gets the menu configuration(s).
Parameters:
Returns:
anything or .textMenuConfiguration
Returns the configuration value(s).
-
Game.TextMenu:Set (configs[, ...])
-
Sets the menu configuration(s).
Parameters:
- configs
Game.TextMenu.CONFIG or .textMenuConfiguration
The configuration to set (Name of the configuration | Configurations table).
- ...
The configuration parameters to set (Ignored if
configs is a table).
(optional)
Returns:
self
This text menu.
-
Game.TextMenu:GetSelectableItems ()
-
Gets all selectable items from this menu.
Returns:
table
All selectable items.
-
Game.TextMenu:GetItem (index)
-
Gets an item from this menu.
Parameters:
- index
number
The menu item index.
Returns:
.textMenuItemProperty
A menu item property.
-
Game.TextMenu:AddItem (displayText[, userData[, isDisabled=false[, isVisualOnly=false[, pos]]]])
-
Adds an item to this menu.
Parameters:
- displayText
string or .textMenuAddOption
The display text. | Options table.
- userData
anything
A variable for storing arbitrary data (Ignored if
displayText is a table).
(optional)
- isDisabled
boolean
The item has grey color and won't invokes callback (Ignored if
displayText is a table).
(default false)
- isVisualOnly
boolean
The item should be a visual shift only (not shifting the slot numbering down)(Ignored if
displayText is a table).
(default false)
- pos
number
The menu item position (Ignored if
displayText is a table).
(optional)
Returns:
self
This text menu.
-
Game.TextMenu:AddText (displayText[, isVisualOnly=false[, pos]])
-
Adds a text line to this menu.
Parameters:
- displayText
string or .textMenuAddOption
The display text. | Options table.
- isVisualOnly
boolean
The line should be a visual shift only (not shifting the slot numbering down)(Ignored if
displayText is a table).
(default false)
- pos
number
The menu item position (Ignored if
displayText is a table).
(optional)
Returns:
self
This text menu.
-
Game.TextMenu:AddBlank ([isVisualOnly=false[, pos]])
-
Adds a blank line to this menu.
Parameters:
- isVisualOnly
boolean or .textMenuAddOption
The line should be a visual shift only (not shifting the slot numbering down). | Options table.
(default false)
- pos
number
The menu item position (Ignored if
isVisualOnly is a table).
(optional)
Returns:
self
This text menu.
-
Game.TextMenu:Open ([player=nil[, displayTime=-1[, pageIndex=1]]])
-
Opens this menu.
Parameters:
- player
Game.Player, nil or .textMenuOpenOption
A player that receive this menu. | All connected players will receive this menu. | Options table.
(default nil)
- displayTime
number
If >=0 menu will timeout after this many seconds (maximum = 255 seconds)(-2 = Don't change currently time set)(Ignored if
player is a table).
(default -1)
- pageIndex
number
Page to start from (starting from 1)(Ignored if
player is a table).
(default 1)
Returns:
self
This text menu.
-
Game.TextMenu:Close (player)
-
Closes a player's menu.
Effectively forcing the player to select exit slot.
The menu will removed on their screen, any results are invalidated and the callback is invoked.
Parameters:
- player
Game.Player
The player.
Returns:
self
This text menu, if any.
-
Game.TextMenu:GetItemCount ()
-
Gets the number of selectable items in this menu.
Returns:
number
The number of selectable items in this menu.
-
Game.TextMenu:GetMaxItemPerPage ()
-
Gets allowed maximum items per page.
Returns:
number
Maximum items per page.
-
Game.TextMenu:GetPageCount ()
-
Gets the number of pages in this menu.
Returns:
number
The number of pages in this menu.
-
Game.TextMenu:ToString ()
-
Returns the title of this menu.
Returns:
string
The title of this text menu.
-
Game.TextMenu:OnSlotSelected (player, slot, page, item)
-
Called when this menu's slot is selected.
Note: This event is using Hook management.
Parameters:
- player
Game.Player
The player who accessing this menu.
- slot
number or Common.TextMenu.STATUS
The selected item slot. | The menu status code.
- page
number
Current menu page index.
- item
.textMenuItemProperty or nil
The menu item property.
See also:
-
Game.TextMenu.__index
-
Base class.
-
Game.TextMenu.__tostring
-
Returns the title of this menu.