Module:Data

local p = {}

function p.load(dataFile) if not dataFile then return 'Error: Specify data page to load.' end title=mw.title.new(mw.text.trim(dataFile)) if not title then return 'Error: Page does not exist' end content=title:getContent entry=mw.text.split(mw.text.trim(content), "%s*\n%s*") tbl={} for i=1, #entry do		parts=splitt(entry[i], "::") if (parts[1] ~= '') and (parts[2] ~= nil) then tbl[parts[1]]=parts[2] end end return tbl end

function splitt(line, pattern) local rtrn={} while true do local front = string.gsub(line, pattern .. ".*", "") table.insert(rtrn, front) line = string.gsub(line, "^.-" .. pattern, "") if not string.find(line, pattern) then break end end table.insert(rtrn, (string.gsub(line, "%s*$", ""))) return rtrn end

return p