Module:Zone

local getArgs = require('Module:Arguments').getArgs local loader = require('Module:Loader')

local string, table, color = loader.require('String', 'Table', 'Color') local zonedata, aliases = loader.loadData('Zone/Data', 'Zone/Aliases') local colorText = color._colorTemplates

local function flatZoneTable(t) local ret = {} for k, v in pairs(t) do		if type(v) == 'table' and not v.name then -- multi-layer table for k1, v1 in pairs(v) do				ret[k1] = v1			end else ret[k] = v		end end return ret end zonedata = flatZoneTable(table.deepCopy(zonedata, true))

local p = {}

- -- Template: Zone -- -- Creates a colored zone link. - function p.zone(frame) local args = getArgs(frame) return p._zone(args[1]) end

local function flatZoneTable(t) local ret = {} for k, v in ipairs(t) do		if type(v) == 'table' and not v.name then -- multi-layer table for k1, v1 in ipairs(v) do				ret[k1] = v1			end else ret[k] = v		end end return ret end

- -- function: _zone(zone: string) -- -- Creates a Colored string based off of the Skyblock Zone. - function p._zone(zone) local _zone = zonedata[aliases[zone:lower]] if not _zone then return formattedError('Invalid zone: %q', 2, zone) end if not _zone.color then return formattedError('Missing color for zone: %q', 2, _zone.name) end return string.makeLink(_zone.name, colorText(_zone.color, { '⏣ ', _zone.name })) end

return p