Hooks hooks
Hooks called by Flux
Summary
Hooks
extends, after the base class has been copied into it.Config.request.Plugin.add_hooks) throws an error.sh_schema.lua, its extra folders and all of its plugins have been included, right before the schema itself is registered.Plugin.set_disabled: on the server right after the new state has been saved, and on every client once the server has told it.Plugin.include_schema, once all plugins have been loaded and the schema has been registered.URLMaterial or util.cache_url_material has been downloaded and turned into a material.Plugin.add_extra.Plugin.include_schema, before the dependencies of the schema, the schema itself and its plugins are included.Config.import is about to set.string.is_command checks a text that starts with one of the command prefixes.Hooks
Called once the Flux package, all of its dependencies and the schema with its plugins have been included. Runs on both the server and the client, on boot and again every time a code refresh reloads the package.
Called from
Call sites
- lib/flux.lua:49 shared
Called when a class is given a base class with extends, after the base class has been
copied into it.
Runs on the realm the class is defined on. Classes that get their base class through
the second argument of class do not run it.
Parameters
- new_class Map the class that is being created
- parent_class Map the base class it extends
Called from
Call sites
- lib/stdlib/sh_class.lua:220 shared
Called on the client when the server reports that a config has got a pending value, or that its pending value is gone. Pending values belong to the configs that need a restart and are only sent to the players who may edit configs.
Parameters
- key String config key
- is_pending Boolean whether the config has a pending value now
- value Any value the config takes on the next start of the server, nil if nothing is pending
See also
Call sites
- lib/config.lua:845 client
Called on the client when the value of a config has arrived from the server and has
been stored: when the player joins, whenever the config is changed on the server and
after Config.request. The value of a private config only arrives if the player may
edit configs, and nil arrives for it once they have lost that right.
Parameters
- key String config key
- old_value Any value the client had before
- new_value Any value that has been received
Call sites
- lib/config.lua:821 client
Called when the value of a config is about to change, before the new value is stored.
On the server it runs for every Config.set, which includes the defaults set by
Config.read and the values set by Config.import. On the client it only runs for
values set locally with Config.set, not for the ones received from the server,
which run OnConfigReceived instead.
Config.load and the client side Config.set call it through Plugin.call, which
skips gamemode handlers.
Parameters
- key String config key
- old_value Any current value, nil if the config has just been created
- new_value Any value that is about to be stored
Called from
Call sites
- lib/config.lua:411 server
- lib/config.lua:425 server
- lib/config.lua:536 server
- lib/config.lua:700 client
Called when a handler from the hook cache (a plugin's, the schema's or one
added with Plugin.add_hooks) throws an error.
Only runs outside of the production environment, where these handlers are
called through pcall. An error inside of an OnHookError handler does not run
the hook again.
Parameters
- name String name of the hook whose handler has failed
- entry Map hook cache entry: the handler at index 1, the table it belongs to at index 2 and the ID given to
Plugin.add_hooksin theidfield
Called from
Call sites
- lib/plugin.lua:1296 shared
Called once the schema's sh_schema.lua, its extra folders and all of its plugins have
been included, right before the schema itself is registered.
Runs on both the server and the client. Plugins commonly use it to run registration hooks
of their own, since every plugin is able to answer them by now. On the first load the
schema's functions are not in the hook cache yet at this point; the schema can use
OnSchemaLoaded instead.
Called from
Call sites
- lib/plugin.lua:990 shared
Called when a plugin has been disabled or enabled with Plugin.set_disabled: on the
server right after the new state has been saved, and on every client once the server
has told it. The plugin itself is not loaded or unloaded at this point, the change
takes effect after the server has restarted.
Parameters
- id String normalized ID of the plugin, see
Plugin.normalize_id - disabled Boolean true if the plugin will be disabled after the restart, false if it will be enabled
Called from
Call sites
- lib/plugin.lua:681 server
- lib/plugin.lua:720 client
Called at the end of Plugin.include_schema, once all plugins have been loaded and the
schema has been registered.
Runs on both the server and the client.
Called from
Call sites
- lib/plugin.lua:1002 shared
Called on the client when an image requested with URLMaterial or
util.cache_url_material has been downloaded and turned into a material.
Images that are on disk already are loaded without running this hook.
Parameters
- url String URL the image was downloaded from
- material Material the downloaded image
Call sites
- lib/stdlib/cl_utils.lua:260 client
Called for every extra folder of a plugin or of the schema before Flux includes it: the
default ones such as 'lib' or 'config' and those added with Plugin.add_extra.
Lets a plugin load the folders it has added in its own way, as the items and factions
plugins do. Runs on both the server and the client, whether the folder exists or not.
Parameters
- extra String name of the extra folder, relative to the plugin's folder
- folder String folder of the plugin or schema, without a trailing slash
Returns
- Boolean Return any value other than nil to take the folder over, so that Flux does not include it itself
Called from
Call sites
- lib/plugin.lua:1220 shared
Called at the start of Plugin.include_schema, before the dependencies of the schema,
the schema itself and its plugins are included.
Runs on both the server and the client, on boot and again on every code refresh. The
list of disabled plugins is known by then, see Plugin.is_disabled.
Called from
Call sites
- lib/plugin.lua:932 shared
Called on the server for every key that Config.import is about to set.
Parameters
- key String config key
- value Any value read from the imported file or table
Returns
- Boolean Return any value other than nil to skip the key and keep its current value
Called from
Call sites
- lib/config.lua:909 server
Called when string.is_command checks a text that starts with one of the command
prefixes.
Lets plugins keep such a text from being treated as a command, as the Prefixes plugin
does for its chat prefixes. Runs on both the server and the client.
Parameters
- text String the text being checked
Returns
- Boolean Return false to have the text treated as regular text instead of a command
Called from
Call sites
- lib/stdlib/sh_string.lua:236 shared