diff --git a/player/lua.c b/player/lua.c index 9e5e2c96a5..8b0a818ea5 100644 --- a/player/lua.c +++ b/player/lua.c @@ -823,29 +823,6 @@ static int script_format_time(lua_State *L) return 1; } -static int script_get_opt(lua_State *L) -{ - struct MPContext *mpctx = get_mpctx(L); - - mp_dispatch_lock(mpctx->dispatch); - - char **opts = mpctx->opts->lua_opts; - const char *name = luaL_checkstring(L, 1); - int r = 0; - - for (int n = 0; opts && opts[n] && opts[n + 1]; n++) { - if (strcmp(opts[n], name) == 0) { - lua_pushstring(L, opts[n + 1]); - r = 1; - break; - } - } - - mp_dispatch_unlock(mpctx->dispatch); - - return r; -} - struct fn_entry { const char *name; int (*fn)(lua_State *L); @@ -881,7 +858,6 @@ static struct fn_entry fn_list[] = { FN_ENTRY(input_set_section_mouse_area), FN_ENTRY(format_time), FN_ENTRY(enable_messages), - FN_ENTRY(get_opt), }; // On stack: mp table diff --git a/player/lua/defaults.lua b/player/lua/defaults.lua index 4f90b1d234..f8fe05ff82 100644 --- a/player/lua/defaults.lua +++ b/player/lua/defaults.lua @@ -4,6 +4,15 @@ function mp.get_script_name() return mp.script_name end +function mp.get_opt(key, def) + local opts = mp.get_property_native("options/lua-opts") + local val = opts[key] + if val == nil then + val = def + end + return val +end + local callbacks = {} -- each script has its own section, so that they don't conflict local default_section = "input_dispatch_" .. mp.script_name