Module:OOO/Data: Difference between revisions
Appearance
Created page with "local M = {} local buckets = { Buildings = mw.loadData('Module:OOO/Data/Buildings'), Vehicles = mw.loadData('Module:OOO/Data/Vehicles'), Resources = mw.loadData('Module:OOO/Data/Resources'), } local function norm(id) return tostring(tonumber(id) or id) end function M.get(domain, id) local t = domain and buckets[domain] if not t or not id then return nil end return t[norm(id)] end -- Optional convenience: "Domain:ID" (e.g., "Buildings:400113") function M...." |
(No difference)
|
Revision as of 20:20, 6 October 2025
Documentation for this module may be created at Module:OOO/Data/doc
local M = {}
local buckets = {
Buildings = mw.loadData('Module:OOO/Data/Buildings'),
Vehicles = mw.loadData('Module:OOO/Data/Vehicles'),
Resources = mw.loadData('Module:OOO/Data/Resources'),
}
local function norm(id) return tostring(tonumber(id) or id) end
function M.get(domain, id)
local t = domain and buckets[domain]
if not t or not id then return nil end
return t[norm(id)]
end
-- Optional convenience: "Domain:ID" (e.g., "Buildings:400113")
function M.lookup(key)
local domain, id = tostring(key or ""):match("^([^:]+):(.+)$")
if domain and id then return M.get(domain, id) end
return nil
end
return M