diff options
author | wm4 <wm4@nowhere> | 2014-11-28 23:18:50 +0100 |
---|---|---|
committer | Diogo Franco (Kovensky) <diogomfranco@gmail.com> | 2015-01-25 17:00:11 +0900 |
commit | 5f6b5feac6d55e69c01858b314da6184c5f547c5 (patch) | |
tree | c99e15b494c4e8ad62457cd8a25d5c29883d43cf /TOOLS | |
parent | e2a4fde6de8e2173160746a5e687b9a5d2d387c9 (diff) | |
download | mpv-5f6b5feac6d55e69c01858b314da6184c5f547c5.tar.bz2 mpv-5f6b5feac6d55e69c01858b314da6184c5f547c5.tar.xz |
lua: add a function that formats Lua values as strings
Yep, Lua is so crappy that the stdlib doesn't provide anything like
this.
Repurposes the undocumented mp.format_table() function and moves it to
mp.utils.
Diffstat (limited to 'TOOLS')
-rw-r--r-- | TOOLS/lua/observe-all.lua | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/TOOLS/lua/observe-all.lua b/TOOLS/lua/observe-all.lua index 68e09773c6..9bfdf44992 100644 --- a/TOOLS/lua/observe-all.lua +++ b/TOOLS/lua/observe-all.lua @@ -1,16 +1,10 @@ -- Test script for property change notification mechanism. -function format_property_val(v) - if type(v) == "table" then - return mp.format_table(v) -- undocumented function; might be removed - else - return tostring(v) - end -end +local utils = require("mp.utils") for i,name in ipairs(mp.get_property_native("property-list")) do mp.observe_property(name, "native", function(name, val) print("property '" .. name .. "' changed to '" .. - format_property_val(val) .. "'") + utils.to_string(val) .. "'") end) end |