Module:MKWorld map
From the Super Mario Wiki, the Mario encyclopedia
Jump to navigationJump to search
This module outputs {{MKWorld map}}.
local MISSIONS = mw.loadJsonData('Module:MKWorld missions/data.json')
local MAP_SIZE = 1000
local ICON_SIZE = 16
local p = {}
function p.normalizepos(pos)
return {
math.floor((pos[1] / 7000 * 0.5 + 0.5) * MAP_SIZE),
math.floor((pos[2] / 7000 * 0.5 + 0.5) * MAP_SIZE)
}
end
function p.main(frame)
local wikitext = ""
wikitext = wikitext .. "<div style=\"position:relative;\">"
wikitext = wikitext .. "<imagemap>"
wikitext = wikitext .. "File:MKW Map with Roads Artwork.png|frameless|" .. MAP_SIZE .. "px"
for k, v in pairs(MISSIONS) do
local pos = p.normalizepos(v.pos)
local x = pos[1]
local z = pos[2]
wikitext = wikitext .. "\nrect " .. x .. " " .. z .. " " .. (x + ICON_SIZE) .. " " .. (z + ICON_SIZE) .. " [[List of Mario Kart World missions#" .. k .. "]]"
end
wikitext = wikitext .. "</imagemap>"
for k, v in pairs(MISSIONS) do
local pos = p.normalizepos(v.pos)
local x = pos[1]
local z = pos[2]
wikitext = wikitext .. "<div style=\"pointer-events:none;position:absolute;top:" .. z .. "px;left:" .. x .. "px;\">"
wikitext = wikitext .. "[[File:MKLHC pswitch.png|" .. ICON_SIZE .. "px]]"
wikitext = wikitext .. "</div>"
end
wikitext = wikitext .. "</div>"
return frame:preprocess(wikitext)
end
return p