Module:Minimap

-- local p = {}

local getArgs = require('Module:Arguments').getArgs require('Module:LibraryUtil')

-- Map data local maps = { ["the park"]= { imageClass="minimap-park", topLeftCoord={ 480.5, 141.65 }, -- origin={ 2461, 1228 }, origin={ 4164, 1228 }, mapScale=0.1153846153846154, } }

function p.getMap(frame) local args = getArgs(frame) local location = args["location"] or args[1] local x = args["x"] local y = args["y"] or 71 local z = args["z"] local width = args["width"] or args["size"] or 350 local height = args["height"] or args["size"] or 350 assertTrue(location, "location must be specified", 0) assertTrue(x, "x must be specified", 0) assertTrue(z, "z must be specified", 0) return p._getMap(location, x, y, z, width, height) end

function p._getMap(location, x, y, z, width, height) local mapData = maps["the park"] local imgOffsetX = -(mapData.origin[1] + (x/mapData.mapScale)) + (width*0.5) local imgOffsetY = -(mapData.origin[2] + (z/mapData.mapScale)) + (height*0.5) return mw.html.create('div') :addClass("hsw-minimap") :addClass(mapData.imageClass) :css({ width=width.."px", height=height.."px", ["background-position"]= imgOffsetX.."px "..imgOffsetY.."px" }) end

return p