summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
Diffstat (limited to 'player')
-rw-r--r--player/lua.c14
-rw-r--r--player/lua/defaults.lua2
-rw-r--r--player/lua/options.lua6
-rw-r--r--player/scripting.c25
4 files changed, 32 insertions, 15 deletions
diff --git a/player/lua.c b/player/lua.c
index 7f7fb69bce..992c237867 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -279,10 +279,16 @@ static void set_path(lua_State *L)
const char *path = lua_tostring(L, -1);
char *newpath = talloc_strdup(tmp, path ? path : "");
- char **luadir = mp_find_all_config_files(tmp, get_mpctx(L)->global, "lua");
- for (int i = 0; luadir && luadir[i]; i++) {
- newpath = talloc_asprintf_append(newpath, ";%s",
- mp_path_join(tmp, bstr0(luadir[i]), bstr0("?.lua")));
+ char *dirs[] = {"scripts", "lua", NULL};
+ for (int s = 0; dirs[s]; s++) {
+ char **luadir = mp_find_all_config_files(tmp, get_mpctx(L)->global,
+ dirs[s]);
+ for (int i = 0; luadir && luadir[i]; i++) {
+ // No need to display a warning for lua files in the deprecated
+ // 'lua' dirs since scripting.c already warned on them
+ newpath = talloc_asprintf_append(newpath, ";%s",
+ mp_path_join(tmp, bstr0(luadir[i]), bstr0("?.lua")));
+ }
}
lua_pushstring(L, newpath); // package path newpath
diff --git a/player/lua/defaults.lua b/player/lua/defaults.lua
index bb4eb648ce..4cdeef497f 100644
--- a/player/lua/defaults.lua
+++ b/player/lua/defaults.lua
@@ -14,7 +14,7 @@ function mp.get_script_name()
end
function mp.get_opt(key, def)
- local opts = mp.get_property_native("options/lua-opts")
+ local opts = mp.get_property_native("options/script-opts")
local val = opts[key]
if val == nil then
val = def
diff --git a/player/lua/options.lua b/player/lua/options.lua
index 6e53c2c48a..087e31b6ef 100644
--- a/player/lua/options.lua
+++ b/player/lua/options.lua
@@ -79,18 +79,18 @@ function read_options(options, identifier)
end
--parse command-line options
- for key, val in pairs(mp.get_property_native("options/lua-opts")) do
+ for key, val in pairs(mp.get_property_native("options/script-opts")) do
local prefix = identifier.."-"
if not (string.find(key, prefix, 1, true) == nil) then
key = string.sub(key, string.len(prefix)+1)
-- match found values with defaults
if options[key] == nil then
- msg.warn("lua-opts: unknown key " .. key .. ", ignoring")
+ msg.warn("script-opts: unknown key " .. key .. ", ignoring")
else
local convval = typeconv(options[key], val)
if convval == nil then
- msg.error("lua-opts: error converting value '" .. val ..
+ msg.error("script-opts: error converting value '" .. val ..
"' for key '" .. key .. "'")
else
options[key] = convval
diff --git a/player/scripting.c b/player/scripting.c
index f2ddcec2aa..2ad45075b0 100644
--- a/player/scripting.c
+++ b/player/scripting.c
@@ -179,7 +179,7 @@ void mp_load_scripts(struct MPContext *mpctx)
mp_load_script(mpctx, "@osc.lua");
if (mpctx->opts->lua_load_ytdl)
mp_load_script(mpctx, "@ytdl_hook.lua");
- char **files = mpctx->opts->lua_files;
+ char **files = mpctx->opts->script_files;
for (int n = 0; files && files[n]; n++) {
if (files[n][0])
mp_load_script(mpctx, files[n]);
@@ -187,13 +187,24 @@ void mp_load_scripts(struct MPContext *mpctx)
if (!mpctx->opts->auto_load_scripts)
return;
- // Load all lua scripts
+ // Load all scripts
void *tmp = talloc_new(NULL);
- char **luadir = mp_find_all_config_files(tmp, mpctx->global, "lua");
- for (int i = 0; luadir && luadir[i]; i++) {
- files = list_script_files(tmp, luadir[i]);
- for (int n = 0; files && files[n]; n++)
- mp_load_script(mpctx, files[n]);
+ const char *dirs[] = {"scripts", "lua", NULL}; // 'lua' is deprecated
+ int warning_displayed = 0;
+ for (int s = 0; dirs[s]; s++) {
+ char **scriptsdir = mp_find_all_config_files(tmp, mpctx->global, dirs[s]);
+ for (int i = 0; scriptsdir && scriptsdir[i]; i++) {
+ files = list_script_files(tmp, scriptsdir[i]);
+ for (int n = 0; files && files[n]; n++) {
+ if (s && !warning_displayed) {
+ warning_displayed = 1;
+ MP_WARN(mpctx,
+ "warning: '%s' - '%s' dirs are deprecated. Please move scripts to '%s'.",
+ files[n], dirs[s], dirs[0]);
+ }
+ mp_load_script(mpctx, files[n]);
+ }
+ }
}
talloc_free(tmp);
}