Hints shows the player a random gameplay hint as a notification every five minutes.
Plugins register their own hints with Hints:add, optionally with a color, a sound and a
callback that decides whether the hint may be shown at the moment; Hints:remove takes a
hint out again, Hints:find looks one up and Hints:all lists them. A plugin that cannot
be sure that this one is loaded registers its hints from the RegisterHints hook, which
only this plugin runs. The plugin registers a few general hints itself.
Once a minute the plugin checks whether the interval has passed since the last hint. If it
has, a hint is picked at random among those that may be shown right now: the ones whose
callback allows them and which no ShouldDisplayHint handler holds back. When none may be
shown, the plugin tries again a minute later. The same hint is not shown twice in a row
as long as there is another one to show.
The interval is the default_interval constant at the top of cl_plugin.lua, in seconds;
a schema or a plugin changes it with Hints:set_interval, and an interval of zero turns
the automatic hints off. Because the check runs once a minute, the interval is in effect
rounded up to whole minutes.
With the Settings plugin loaded the player can turn the hints off with the 'show_hints'
setting. Hints:display shows a hint regardless of all of the above. The whole plugin,
the Hints global included, lives on the client.
Summary
Hooks
Methods
Hooks
Implements hook OneMinute
Displays a random hint if the interval has passed since the last one. If there is no hint to show, the next attempt is made a minute later.
Implements hook OnSchemaLoaded
Lets the other plugins and the schema register their hints once all of them are loaded.
Implements hook RegisterClientSettings
Registers the 'show_hints' setting, which lets the player turn the hints off.
Methods
Registers a hint that Hints:display_random can pick. Registering an ID again replaces the hint and keeps its place in the list.
Hints:add('forums', 'hint.forums')
Hints:add('inventory', 'hint.inventory', Color(255, 255, 255), true, function()
return PLAYER:Alive()
end)
-- From a plugin that does not depend on this one:
function MyPlugin:RegisterHints()
Hints:add('my_plugin', 'hint.my_plugin')
end
Parameters
- id String identifier of the hint
- text String phrase id or plain text, translated when the hint is displayed
- color Color optional, defaults to
niltext color of the notification - play_sound Boolean optional, defaults to
falseplay a blip sound when the hint is displayed - callback Function optional, defaults to
nilcalled without arguments whenever a random hint is about to be picked; the hint can only be picked if it returns a truthy value
Returns
- Map the registered hint with the id, text, color, play_sound and callback fields, or nil if the id or the text is not a string
Returns every registered hint.
Returns
- List<Map> hints in the order they have been registered in
Checks whether a hint may be picked right now: its callback, if it has one, has to allow it, and no ShouldDisplayHint handler may hold it back.
Parameters
- hint Map registered hint
Returns
- Boolean true if the hint may be picked
Shows a hint as a notification for 15 seconds, right away and whether or not it could be picked at random: neither its callback nor the 'show_hints' setting is looked at.
Hints:display('inventory')
Parameters
- hint String/Map identifier of a registered hint, or the hint itself
Returns
- Boolean true if the hint has been shown, false if there is no such hint
Picks a random hint among those that may be shown right now and shows it as a notification for 15 seconds. Nothing is shown if the player has turned the hints off or if no hint may be shown at the moment.
Returns
- Map the hint that has been shown, or nil if nothing has been shown
Returns a registered hint.
Parameters
- id String identifier of the hint
Returns
- Map the hint with the id, text, color, play_sound and callback fields, or nil if there is no such hint
Returns the hints that may be picked right now.
Returns
- List<Map> hints for which Hints:can_display is true
Returns the time that passes between two automatic hints.
Returns
- Number interval in seconds; zero or less means that no hints are shown automatically
Checks whether the player wants to see hints: the 'show_hints' setting of the Settings plugin.
Returns
- Boolean false if the player has turned the hints off, true otherwise and when the Settings plugin is not loaded
Picks a random hint among those that may be shown right now. The hint that has been displayed last is left out as long as there is another one to pick.
Returns
- Map the picked hint, or nil if no hint may be shown at the moment
Removes a registered hint, so that it is no longer picked.
-- The schema has no use for the hint about the forums.
Hints:remove('forums')
Parameters
- id String identifier of the hint
Returns
- Boolean true if the hint has been removed, false if there is no such hint
Sets the time that passes between two automatic hints. The change applies to the hint that is being waited for as well.
-- A hint every ten minutes.
Hints:set_interval(600)
-- No automatic hints at all.
Hints:set_interval(0)
Parameters
- seconds Number interval in seconds, zero or less to turn the automatic hints off; anything that is not a number restores the default of five minutes