From 3295caca3d21b20ccab19ab3420d07a139b4f200 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 28 Nov 2014 23:18:50 +0100 Subject: 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. --- TOOLS/lua/observe-all.lua | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'TOOLS/lua') 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 -- cgit v1.2.3