diff options
author | wm4 <wm4@nowhere> | 2019-12-20 14:21:16 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-12-20 14:21:16 +0100 |
commit | 478a321dcc62345a09acfd34740dc6d0783ade88 (patch) | |
tree | f4dfe2c02d4692df6d9da0466c22bb6a9bf9e817 /DOCS | |
parent | db1e28f175f94ea44d226f061d81098a2c2cb8ba (diff) | |
download | mpv-478a321dcc62345a09acfd34740dc6d0783ade88.tar.bz2 mpv-478a321dcc62345a09acfd34740dc6d0783ade88.tar.xz |
lua: add a helper for runtime script option changes
A script can use this to easily get runtime updates. (Even if
script-opts is sort of clunky.)
Diffstat (limited to 'DOCS')
-rw-r--r-- | DOCS/man/lua.rst | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/DOCS/man/lua.rst b/DOCS/man/lua.rst index 45fbfd62d0..6c6904c8b3 100644 --- a/DOCS/man/lua.rst +++ b/DOCS/man/lua.rst @@ -566,14 +566,21 @@ command-line. All you have to do is to supply a table with default options to the read_options function. The function will overwrite the default values with values found in the config-file and the command-line (in that order). -``options.read_options(table [, identifier])`` +``options.read_options(table [, identifier [, on_update]])`` A ``table`` with key-value pairs. The type of the default values is important for converting the values read from the config file or command-line back. Do not use ``nil`` as a default value! The ``identifier`` is used to identify the config-file and the command-line options. These needs to unique to avoid collisions with other scripts. - Defaults to ``mp.get_script_name()``. + Defaults to ``mp.get_script_name()`` if the parameter is ``nil`` or missing. + + The ``on_update`` parameter enables run-time updates of all matching option + values via the ``script-opts`` option/property. If any of the matching + options changes, the values in the ``table`` (which was originally passed to + the function) are changed, and ``on_update(list)`` is called. ``list`` is + a table where each updated option has a ``list[option_name] = true`` entry. + There is no initial ``on_update()`` call. This never re-reads the config file. Example implementation:: |