Module:Data

local mt = {}

function mt.__index(t, k)	return function(frame) local data = mw.loadData(k) local i = 1 for _,v in ipairs(frame.args) do			local ty = type(data) if ty ~= 'table' then if frame.args.softfail then return ' Error: Tried to read index "' .. mw.text.nowiki(v) .. '" of mw.loadData("' .. mw.text.nowiki(k) .. '").' .. mw.text.nowiki(table.concat(frame.args, '.', 1, i - 1)) .. ', which is a ' .. ty .. ' '				else error('Tried to read index "' .. v .. '" of mw.loadData("' .. k .. '").' .. table.concat(frame.args, '.', 1, i - 1) .. ', which is a ' .. ty) end end data = data[v] i = i + 1 end return data end end

return setmetatable({}, mt)