Module:SpawnZone

local p = {} p.drawMap= function( f ) local directArgs = f.args local parentArgs = f:getParent.args local args = {} for _, argType in ipairs{ directArgs, parentArgs } do		for key, val in pairs( argType ) do			args[key] = val end end

local ret if args.zones then local zones = mw.text.gsplit(args.zones, '#') local color = "#f00" if args.color then color = args.color end if args.size then local f = mw.title.makeTitle("File",args.image).file local leftmost = f.width local rightmost = 0 local topmost = f.height local bottommost = 0 local zonecoords = {}

for i in zones do               local coords = mw.text.split(i,",") if #coords >= 4 then local left = 10*tonumber(coords[1]) + args.originx local right = 10*tonumber(coords[2]) + args.originx local top = -10*tonumber(coords[4]) + args.originy local bottom = -10*tonumber(coords[3]) + args.originy if left < leftmost then leftmost = left end if right > rightmost then rightmost = right end if top < topmost then topmost = top end if bottom > bottommost then bottommost = bottom end if #coords == 6 then table.insert(zonecoords, {left, right, top, bottom, coords[5], coords[6]}) elseif #coords == 5 then table.insert(zonecoords, {left, right, top, bottom, coords[5]}) else table.insert(zonecoords, {left, right, top, bottom}) end end end local widthmost = rightmost - leftmost + tonumber(args.offset) * 2 local heightmost = bottommost - topmost + tonumber(args.offset) * 2 local most = math.max(widthmost, heightmost) local ratio = 1 if most > tonumber(args.size) then ratio = tonumber(args.size)/most end local mapleft = (leftmost-tonumber(args.offset))*ratio local maptop = (topmost-tonumber(args.offset))*ratio ret = '   ' for i,v in ipairs(zonecoords) do               local width = v[2] - v[1] local height = v[4] - v[3] ret = ret..'' if #v >= 5 then ret = ret..'' if #v == 6 then ret = ret..' '..v[5]..' '..v[6]..'  ' else ret = ret..v[5]..' ' end else ret = ret..' ' end end else ret = '    ' for i in zones do               local coords = mw.text.split(i,",") if #coords == 4 then local left = 10*tonumber(coords[1]) + args.originx local right = 10*tonumber(coords[2]) + args.originx local bottom = -10*tonumber(coords[3]) + args.originy local top = -10*tonumber(coords[4]) + args.originy local width = right - left local height = bottom - top ret = ret..' ' end end end else ret = '    ' end return ret..' ' end p.zone = function(f) local args = f.args local parentArgs = f:getParent.args for _ in pairs( parentArgs ) do       args = parentArgs break end if args.levels then return args.minX..','..args.maxX..','..args.minY..','..args.maxY..','..args.levels..','..args.frequency..'#' elseif args.info then return args.minX..','..args.maxX..','..args.minY..','..args.maxY..','..args.info..'#' else return args.minX..','..args.maxX..','..args.minY..','..args.maxY..'#' end end return p