Commit d3480941 authored by Antoine Cellerier's avatar Antoine Cellerier

Simplify lua http's custom.lua. Print any errors while loading custom.lua in the debug output.

parent 054c7f95
local _G = _G
module("custom",package.seeall)
local dialogs_cache = {}
local dialogs = setmetatable({}, {
__index = function(self, name)
-- Cache the dialogs
return rawget(self, name) or
rawget(rawset(self, name, process(http_dir.."/dialogs/"..name)), name)
end})
function dialog_preload(name)
if not dialogs_cache[name] then
-- Cache the dialogs
dialogs_cache[name] = process(http_dir.."/dialogs/"..name)
_G.dialogs = function(...)
for i=1, select("#",...) do
dialogs[(select(i,...))]()
end
end
function dialog(name)
dialog_preload(name)
dialogs_cache[name]()
end
function dialogs(...)
for i=1,select("#",...) do
dialog(select(i,...))
end
end
_G.dialogs = dialogs
_G.vlm = vlc.vlm()
......@@ -258,7 +258,7 @@ do
package.path = http_dir.."/?.lua"
local ok, err = pcall(require,"custom")
if not ok then
vlc.msg.warn("Couldn't load "..http_dir.."/custom.lua")
vlc.msg.warn("Couldn't load "..http_dir.."/custom.lua",err)
else
vlc.msg.dbg("Loaded "..http_dir.."/custom.lua")
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment