Module:MapLocations

local p = {} function p.maplocations( f ) local args = f:getParent.args -- set default values (borderCoords are for top, right, bottom, left) local map, borderCoords, mapsize, markersize, markercolor, markericon, opacity, text, float = 'Map The Island.jpg', {t=7.2,r=92.8,b=92.8,l=7.2}, 300, 10, '#f40',, 1, , ''

-- get values from parameters if args.map ~= nil then map = args.map -- if the map is given as just the name, apply the default map-file if map == 'The Island' then map = 'The Island Topographic Map.jpg' elseif map == 'The Center' then map = 'The Center Topographic Map.jpg' elseif map == 'Scorched Earth' then map = 'Scorched Earth Topographic Map.jpg' elseif map == 'Ragnarok' then map = 'Ragnarok Topographic Map.jpg' elseif map == 'Aberration' then map = 'Aberration Topographic Map.jpg' end

-- use the default borders of the chosen map if map == 'The Center Topographic Map.jpg' then borderCoords = {t=-2.0,r=100.0,b=100.0,l=0.0} elseif map == 'Scorched Earth Topographic Map.jpg' then borderCoords = {t=0.0,r=100.0,b=100.0,l=0.0} elseif map == 'Ragnarok Topographic Map.jpg' then borderCoords = {t=11,r=89,b=89,l=11} elseif map == 'Ragnarok Ocean Topographic Map.jpg' then borderCoords = {t=-2.6,r=102.4,b=102.4,l=-2.6} elseif map == 'Ragnarok Map.png' then borderCoords = {t=0.0,r=100.0,b=100.0,l=0.0} elseif map == 'Aberration Topographic Map.jpg' then borderCoords = {t=7.2,r=92.8,b=92.8,l=7.2} end end if args.mapsize ~= nil then mapsize = args.mapsize end if args.markersize ~= nil and tonumber(args.markersize) ~= nil and tonumber(args.markersize) >= 0 then markersize = tonumber(args.markersize) end if args.markercolor ~= nil then markercolor = args.markercolor end if args.markericon ~= nil then markericon = args.markericon end if args.opacity ~= nil then opacity = args.opacity end if args.text ~= nil then text = args.text end if args.float ~= nil then float = args.float end if args.borderCoordT ~= nil then borderCoords.t = args.borderCoordT end if args.borderCoordR ~= nil then borderCoords.r = args.borderCoordR end if args.borderCoordB ~= nil then borderCoords.b = args.borderCoordB end if args.borderCoordL ~= nil then borderCoords.l = args.borderCoordL end

-- variables for a single marker: lat, lon, ms (markersize), mc (markercolor), mt (markertext/title/tooltip), mis (markericons) local locations, lat, lon, ms, mc, mt, mis = {}, 0, 0, 0, ,, {} for _,l in ipairs(args) do   ms = markersize mc = markercolor mis = {} mis[1] = markericon local parts,i = {},0 for part in string.gmatch(l..',', "([^,]*),") do     table.insert(parts,part:match "^%s*(.-)%s*$") end

if #parts > 1 then lat = parts[1] lon = parts[2] mt = 'lat '..lat..', lon '..lon if #parts > 2 and string.len(parts[3])>0 then ms = parts[3] end if #parts > 3 and string.len(parts[4])>0 then mc = parts[4] end if #parts > 4 and string.len(parts[5])>0 then mt = parts[5]..'&#010;'..mt     end i=5 while #parts > i do       mis[i-4] = parts[i+1] i = i + 1 end if #mis > 0 and string.len(mis[1]) > 0 then table.insert(locations,'   ') else table.insert(locations,' ') end end end local subtitle = '' if text ~= '' then subtitle = '\n|-\n| align="middle" | '..text end return '{| class="wikitable" style="float:'..float..'"\n|-\n| '..table.concat(locations)..' '..subtitle..'\n|}' end return p