Commit Graph

15 Commits

Author SHA1 Message Date
Dudemanguy fcc67cc6c1 lua: remove a ton of unneeded parentheses
For whatever reason, some of the lua code (particularly the osc and
ytdl_hook) is full of a bunch of stuff like if (foo), if not (foo ==
nil), etc. The parenthesis aren't needed in lua and actually just look
weird since nobody actually writes lua like this. You can see most of
the other conditionals are written normally. So cleanup the style to
match when the parenthesis clearly aren't doing anything. Not directly
related, but also add some spaces on a few math operations while we're
at it.
2023-11-02 16:03:20 +00:00
Christoph Heinrich 83acd93c6a lua: read_options: find script-opts prefix at index 1 exactly
Finding the prefix in the key is not enough, the key has to actually
start with the prefix. Otherwise a key like `uosc-font_scale` will not
only match the `uosc-` prefix, but also the `osc-` prefix, resulting
in a logged warning about `-font_scale` being an unknown key.
2023-06-01 15:11:55 +03:00
Guido Cella 4d12dfb75a options.lua: remove unused function
val2str isn't used anywhere. Its only use was removed in dd3e52fe68,
when it was still part of osc.lua.
2022-04-08 19:20:49 +03:00
Avi Halachmi (:avih) 8a597a484b lua: read_options: quote values at error messages
This makes it easier to understand the error in cases of incorrect
syntax or formatting at .conf files. (js already has this quoting).

Fixes #9105
2021-08-10 11:00:18 +03:00
wm4 1b03970d79 lua: windows got what users crave
It's got '\r's.

Fixes: #7733
2020-05-27 15:01:39 +02:00
Oscar Manglaras c99cc13526 options.lua: avoid unnecessary on_update calls
The script was set up to only call on_update when the changelist
was non-empty. However, since the size operator does not operate
on dicts, it always returned 0 (which is truthy), thus on_update
would always be called when the script-opts property changed.
2020-02-06 22:57:53 +01:00
wm4 00af718a9e lua: change runtime option change behavior
As described in the manpage changes. This makes more sense than the
previous approach, where options could "unexpectedly" stick. Although
this is still a somewhat arbitrary policy (ask many people and you'd get
a number of different expectations on what should happen), I think that
it reflects what mpv's builtin stuff does.

All the copying is annoying, but let's just hope nobody is stupid enough
to change these properties per video frame or something equally
ridiculous.
2019-12-22 12:30:53 +01:00
wm4 478a321dcc 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.)
2019-12-20 14:21:16 +01:00
wm4 fdce778605 lua: change config file logging
Make the existing "not found" messages debug only, and add a new verbose
message if a config file was opened. The idea is that logging should
make it apparent whether or not config files are loaded, and it's more
common to use scripts without config files, leading to fewer log
messages in verbose mode.
2019-11-01 01:52:05 +01:00
Avi Halachmi (:avih) 9eadc068fa
config: replace config dir lua-settings/ with dir script-opts/
lua-settings/ is still supported, with deprecation warning.
2018-04-07 16:02:16 -07:00
wm4 327b091909 lua: fix options submodule
It polluted the global namespace, instead of exporting the function
properly.

For now, keep it compatible by explicitly keeping the bogus export.

Also fix a mistake in the manpage example.
2015-05-29 15:50:09 +02:00
Avi Halachmi (:avih) 39e04e9294 options: deprecate 'lua' based options/dirs for 'script'
- --lua and --lua-opts change to --script and --script-opts
- 'lua' default script dirs change to 'scripts'
- DOCS updated

- 'lua-settings' dir was _not_ modified

The old lua-based names/dirs still work, but display a warning.

Signed-off-by: wm4 <wm4@nowhere>
2014-12-15 04:39:56 +01:00
Otto Modinos 33a63d8e6e options.lua: call msg.debug after resolving 'identifier' 2014-09-16 17:34:08 +02:00
ChrisK2 ce69afab44 lua/osc: forgot some changed files in previous commit 2014-05-23 13:24:27 +02:00
ChrisK2 c6915d7325 lua/osc: small overhaul
Small fixes for the OSC, seektooltip now enabled by default.

Option-parser now moved to separate package, can be used from
other scripts, see DOCS/man/en/lua.rst.

OSC config file location moved to lua-settings/osc.conf
2014-05-23 13:14:17 +02:00