summaryrefslogtreecommitdiffstats
path: root/player/lua/defaults.lua
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-02-26 20:58:17 +0100
committerwm4 <wm4@nowhere>2014-02-26 21:03:36 +0100
commit11ee72fe1b4304ae16ff45c767c0d9e8f6e6f295 (patch)
tree956b691a2032397389649ac6074e3e5a5dee5e84 /player/lua/defaults.lua
parent25f086973ff267495586c776e79f91bc5ddc44fa (diff)
downloadmpv-11ee72fe1b4304ae16ff45c767c0d9e8f6e6f295.tar.bz2
mpv-11ee72fe1b4304ae16ff45c767c0d9e8f6e6f295.tar.xz
lua: implement mp.get_opt() in Lua
Will be more expensive if used very often, but it's probably ok. Reduce the dependency of lua.c on MPContext a bit further.
Diffstat (limited to 'player/lua/defaults.lua')
-rw-r--r--player/lua/defaults.lua9
1 files changed, 9 insertions, 0 deletions
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