summaryrefslogtreecommitdiffstats
path: root/player/lua.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-02-01 18:09:40 +0100
committerwm4 <wm4@nowhere>2020-02-01 18:09:40 +0100
commitda38caff9c0bec4745cef16b7904e26e51a4539b (patch)
tree39ea39729f109713d1871f0aed053a156f86c768 /player/lua.c
parent66a979bd757f27739158023f44a943a406a59159 (diff)
downloadmpv-da38caff9c0bec4745cef16b7904e26e51a4539b.tar.bz2
mpv-da38caff9c0bec4745cef16b7904e26e51a4539b.tar.xz
scripting: load scripts from directories
The intention is to provide a slightly nicer way to distribute scripts. For example, you could put multiple source files into the directory, and then import them from the actual script file (this is still unimplemented). At first I wanted to require a config file (because you need to know at least which scripting backend it should use). This wouldn't have been too hard (could have reused/abused the mpv config file parsing mechanism, and I already had working code that was just 2 function calls). But probably better to do this without new config files, because it might become a pain in the distant future. So this just probes for "main.lua", "main.js", etc., until an existing file is found. Another important change is that this skips all directory entries whose name starts with ".". This automatically excludes the "." and ".." special directories, and is probably useful to exclude random crap that might be lying around in the directory (such as editor temporary files, or OSX, in its usual hrmful, annoying, and idiotic modus operandi, sharting all over any directories opened by "Finder"). Although the changelog mentions the docs, they're added only in a later commit.
Diffstat (limited to 'player/lua.c')
-rw-r--r--player/lua.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/player/lua.c b/player/lua.c
index 6423861f16..3d23a307fb 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -337,18 +337,17 @@ static int run_lua(lua_State *L)
return 0;
}
-static int load_lua(struct mpv_handle *client, const char *fname)
+static int load_lua(struct mp_script_args *args)
{
- struct MPContext *mpctx = mp_client_get_core(client);
int r = -1;
struct script_ctx *ctx = talloc_ptrtype(NULL, ctx);
*ctx = (struct script_ctx) {
- .mpctx = mpctx,
- .client = client,
- .name = mpv_client_name(client),
- .log = mp_client_get_log(client),
- .filename = fname,
+ .mpctx = args->mpctx,
+ .client = args->client,
+ .name = mpv_client_name(args->client),
+ .log = args->log,
+ .filename = args->filename,
};
if (LUA_VERSION_NUM != 501 && LUA_VERSION_NUM != 502) {