From 637664d95ad5e2ad72b91998dc4685bf0fe6cdeb Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 17 Mar 2014 18:26:56 +0100 Subject: command, lua: change script_message semantics Change script_message to broadcast the message to all clients. Add a new script_message_to command, which does what the old script_message command did. This is intended as simplification, although it might lead to chaos too. --- DOCS/man/en/input.rst | 21 ++++++++++++++------- DOCS/man/en/lua.rst | 22 +++++++++++++++------- 2 files changed, 29 insertions(+), 14 deletions(-) (limited to 'DOCS') diff --git a/DOCS/man/en/input.rst b/DOCS/man/en/input.rst index f5efb1f49e..5dabc72761 100644 --- a/DOCS/man/en/input.rst +++ b/DOCS/man/en/input.rst @@ -443,13 +443,20 @@ Input Commands that are Possibly Subject to Change Remove an overlay added with ``overlay_add`` and the same ID. Does nothing if no overlay with this ID exists. -``script_message "" "" "" ...`` - Send a message to the client named ````, and pass it the following - list of arguments. The target can be for example a script (Lua scripts - can get their name via ``mp.get_script_name()``). What this message means, - how many arguments it takes, and what the arguments mean is fully up to - the target and the sender. Lua scripts use it to add key bindings via - input.conf. +``script_message "" "" ...`` + Send a message to all clients, and pass it the following list of arguments. + What this message means, how many arguments it takes, and what the arguments + mean is fully up to the receiver and the sender. Every client receives the + message, so be careful about name clashes (or use ``script_message_to``). + +``script_message_to "" "" "" ...`` + Same as ``script_message``, but send it only to the client named + ````. Each client (scripts etc.) has a unique name. For example, + Lua scripts can get their name via ``mp.get_script_name()``. + + (Scripts use this internally to dispatch key bindings, and this can also + be used in input.conf to reassign such bindings.) + Undocumented commands: ``tv_start_scan``, ``tv_step_channel``, ``tv_step_norm``, ``tv_step_chanlist``, ``tv_set_channel``, ``tv_last_channel``, ``tv_set_freq``, diff --git a/DOCS/man/en/lua.rst b/DOCS/man/en/lua.rst index c632553c5c..fc7606a5fc 100644 --- a/DOCS/man/en/lua.rst +++ b/DOCS/man/en/lua.rst @@ -162,13 +162,13 @@ The ``mp`` module is preloaded, although it can be loaded manually with The ``name`` argument should be a short symbolic string. It allows the user to remap the key binding via input.conf using the ``script_message`` - command, the script name, and the name of the key binding (see below for + command, and the name of the key binding (see below for an example). The name should be unique across other bindings in the same script - if not, the previous binding with the same name will be overwritten. You can omit the name, in which case a random name is generated internally. - Internally, key bindings are dispatched via the ``script_message`` input + Internally, key bindings are dispatched via the ``script_message_to`` input command and ``mp.register_script_command``. Trying to map multiple commands to a key will essentially prefer a random @@ -187,17 +187,24 @@ The ``mp`` module is preloaded, although it can be loaded manually with This will print the message ``the key was pressed`` when ``x`` was pressed. - The user can remap these key bindings. Assume the above script was using - the filename ``fooscript.lua``, then the user has to put the following + The user can remap these key bindings. Then the user has to put the following into his input.conf to remap the command to the ``y`` key: :: - y script_message lua/fooscript something + y script_message something + This will print the message when the key ``y`` is pressed. (``x`` will still work, unless the user overmaps it.) + You can also explicitly send a message to a named script only. Assume the + above script was using the filename ``fooscript.lua``: + + :: + + y script_message_to lua/fooscript something + ``mp.add_forced_key_binding(...)`` This works almost the same as ``mp.add_key_binding``, but registers the key binding in a way that will overwrite the user's custom bindings in his @@ -292,8 +299,9 @@ The ``mp`` module is preloaded, although it can be loaded manually with The level is a string, see ``msg.log`` for allowed log levels. ``mp.register_script_command(name, fn)`` - This is a helper to dispatch ``script_message`` invocations to Lua - functions. ``fn`` is called if ``script_message`` is called on this script + This is a helper to dispatch ``script_message`` or ``script_message_to`` + invocations to Lua functions. ``fn`` is called if ``script_message`` or + ``script_message_to`` (with this script as destination) is run with ``name`` as first parameter. The other parameters are passed to ``fn``. If a command with the given name is already registered, it's overwritten. -- cgit v1.2.3