Flux.Help classclient
Part of Active UI
Help: the pages of the Help tab of the tab menu. A page is registered under an ID with
Flux.Help:add_page and shows up as a tab of its own, in the order of the priorities.
Its contents are a Lumen element tree that comes from one of two places: a Lumen template
from a views/lumen folder (the usual way, see Lumen), or a function that returns the
elements. Flux registers three pages itself: 'commands' (every command the local player
may run, see Flux.Help:get_commands), 'plugins' and 'credits'.
The pages are rendered every time the Help tab is opened, in the language of the player, so a page can show what is true at that moment.
-- plugin/cl_plugin.lua, with the page in plugin/views/lumen/rules.lumen
Flux.Help:add_page('rules', {
title = 'ui.help.rules.title',
component = 'rules',
priority = 5
})
Summary
Methods
visible function, if they have one, returns a truthy value.Methods
Adds a page to the Help tab, or replaces the page that has the same ID.
Flux.Help:add_page('server_info', {
title = 'ui.help.server_info.title',
priority = 5,
visible = function(page)
return PLAYER:has_initialized()
end,
render = function(page)
return Lumen.element('text', { style = { font = 'menu_large' } }, { GetHostName() })
end
})
Parameters
- id String unique page ID made of Latin letters, digits and underscores
- data Map page options. Give one of: component (String ID of a Lumen template, or Function a Lumen component; it receives the page as the
pageprop along withprops) or render (Function(page) that returns a Lumen element). Optional: title (String text or phrase shown on the tab of the page, the ID by default), priority (Number pages are ordered by ascending priority, 50 by default), props (Map more props for the component) and visible (Function(page) return a falsy value to leave the page out)
Returns
- Map the stored page, or nil if the ID or the options are not valid
Returns every page that has been added to the Help tab.
Returns
- Map pages keyed by page ID
Returns a page of the Help tab.
Parameters
- id String page ID
Returns
- Map the page, or nil if there is no such page
Returns the prefix to show in front of the names of commands: '/' if that is one of the command prefixes of the server, else the first of them.
Returns
- String
Lists the commands the local player is allowed to run, grouped by category, for the Commands page of the Help tab. A command is listed if the player may run it or one of its subcommands, which are listed with it. The texts are translated to the current language. Commands without a category end up in a category of their own, and categories that translate to the same name are merged.
Returns
- List<Map> categories ordered by name: name (String translated name) and commands (List<Map> ordered by name: id (String), name (String), syntax (String, empty if the command takes no arguments), description (String), aliases (List<String> the other names the command can be called by) and subcommands (List<Map> the subcommands the player may run, in the same form, with their full names such as 'Whitelist add'))
Returns the pages that the Help tab shows right now: the ones whose visible function,
if they have one, returns a truthy value.
Returns
- List<Map> pages ordered by priority, pages of the same priority by ID
Removes a page from the Help tab.
Parameters
- id String page ID
Renders the contents of a page: the element of its component with the page as a prop, or what its render function returns. A page that fails to render is reported in the console and comes out empty, so that it does not take the other pages down with it.
Parameters
- page Map page, as returned by Flux.Help#get_pages or Flux.Help#find_page
Returns
- Map Lumen element of the page, or nil if the page has none