Module:CreatureMap

local p = {} function p.creaturemap( f ) local regions = f:getParent.args local size, opacity, color, link, missingRegions, linktitle, map, mapfile, isCave = '400px', 0.5, , , false, '', 'The Island', 'Map_The_Island.jpg', false local regionDivs, symbolDivs = {}, {} local rarityLegend = {'Very Common', 'Common', 'Uncommon', 'Very Uncommon', 'Rare', 'Very Rare'} local usedRarities = { ['very common'] = false, ['common'] = false, ['uncommon'] = false, ['very uncommon'] = false, ['rare'] = false, ['very rare'] = false, ['untameable'] = false } if regions.size ~= nil then size = regions.size regions.size = nil end if regions.opacity ~= nil then opacity = regions.opacity regions.opacity = nil end if regions.map ~= nil then map = regions.map regions.map = nil end

local regionColorClasses = { ['very common'] = 'cr-region-map-very-common', ['common'] = 'cr-region-map-common', ['uncommon'] = 'cr-region-map-uncommon', ['very uncommon'] = 'cr-region-map-very-uncommon', ['rare'] = 'cr-region-map-rare', ['very rare'] = 'cr-region-map-very-rare', }

local regionData if map == 'The Island' then regionData = mw.loadData( 'Module:CreatureMap/regions' ) elseif map == 'The Center' then regionData = mw.loadData( 'Module:CreatureMap/centerregions' ) mapfile = 'The_Center_Topographic.jpg' elseif map == 'Scorched Earth' then regionData = mw.loadData( 'Module:CreatureMap/scorchedregions' ) mapfile = 'Scorched_Earth_Map.jpg' elseif map == 'Aberration' then regionData = mw.loadData( 'Module:CreatureMap/aberrationregions' ) mapfile = 'Aberration_Map.jpg' end local colors = { ['very common'] = 'cr-region-map-cl-very-common', ['common'] = 'cr-region-map-cl-common', ['uncommon'] = 'cr-region-map-cl-uncommon', ['very uncommon'] = 'cr-region-map-cl-very-uncommon', ['rare'] = 'cr-region-map-cl-rare', ['very rare'] = 'cr-region-map-cl-very-rare', ['unknown'] = 'cr-region-map-cl-unknown' }

for region,rarity in pairs(regions) do   rarity = string.lower(rarity) if rarity ~= 'no' and regionData[region] ~= nil then

isCave = string.sub(region,1,4) == 'cave' local isUntameable rarity, isUntameable = string.gsub(rarity,'%s*untameable%s*','')

if colors[rarity] ~= nil then color = colors[rarity] usedRarities[rarity] = true else color = colors.unknown missingRegions = true end -- show regionshape only if creature surely occurs if color ~= colors.unknown and isCave ~= true then if regionDivs[rarity] == nil then regionDivs[rarity] = {} end table.insert(regionDivs[rarity],' ') end linktitle = '' if string.lower(string.sub(regionData[region].name,1,3)) == 'sea' then link = 'Sea' linktitle = ' title="'..regionData[region].name..'"' else if regionData[region].linktitle ~= nil then linktitle = ' title="'..regionData[region].linktitle..'"' end link = regionData[region].name end local cssClass, cssClassStripes = ' cr-region-map-marker', '' if isCave then cssClass = cssClass .. ' cr-region-map-markercave' end if isUntameable > 0 then cssClassStripes = ' class="stripes"' usedRarities['untameable'] = true end table.insert(symbolDivs,' '..regionData[region].abbr..'  ') end end

local regionDivsContainer = '' for cRarity,cRegions in pairs(regionDivs) do   regionDivsContainer = regionDivsContainer..''..table.concat(cRegions)..' ' end

local missingRegionsText, legendUnknown = ,  if missingRegions then missingRegionsText = ' This creature is missing habitat information. You can help by finding its map locations in-game and updating them ' legendUnknown = ' Unknown' end

local legend, rarityKeys = {}, {'very common','common','uncommon','very uncommon','rare','very rare'} for l=1,6 do   if usedRarities[rarityKeys[l]] then table.insert(legend,' '..rarityLegend[l]..' ') end end

if usedRarities['untameable'] then table.insert(legend,' Untameable ') end

return missingRegionsText..'  '..regionDivsContainer..' '..table.concat(symbolDivs)..'  ' ..' colorblind? '.. -- legend ' '..table.concat(legend)..legendUnknown..' ' end return p