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 p = {}

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))

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

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

return p