Module:AreaMapDisplay
From IdleOn MMO Wiki
Usage:
{{#invoke:AreaMapDisplay|map|WorldImage=Blunder Hills World Map.png}}
Lua error: Error: Table AreaMapDisplayData not found..
The data:
Special:CargoTables/AreaData (edit in Worlds)
local p = {}
local cargo = mw.ext.cargo
function p.map(frame)
local args = frame.args
local WorldImage = args.WorldImage
local results = cargo.query(
'AreaMapDisplayData',
'Area, WorldImage, x, y, Size, ID',
{where = 'WorldImage = "' .. mw.text.nowiki(WorldImage) .. '"'}
)
local root = mw.html.create('div')
:css({
position = 'relative',
left = '0px',
top = '0px',
width = '808px',
height = '428px'
})
-- 画像リンク無効化用DIV(繰り返さない)
root:tag('div')
:css({
position = 'absolute',
left = '0px',
top = '0px',
right = '0px',
bottom = '0px',
z_index = 1,
background_color = 'rgba(0, 0, 0, 0)'
})
-- ベースイメージの設定(繰り返さない)
root:tag('span')
:css({
position = 'absolute',
left = '0px',
top = '0px',
z_index = 0,
width = '808px',
height = '428px'
})
:wikitext('[[File:' .. results[1].WorldImage .. '|808x428px]]')
-- 各エリアごとの地点を追加
for _, record in ipairs(results) do
-- リンク付きポイントを地図上に設置
root:tag('div')
:css({
position = 'absolute',
left = record.x .. 'px',
top = record.y .. 'px',
transform = 'translate(-50%, -50%)',
line_height = '95%',
z_index = 2
})
:wikitext('[[Worlds#' .. record.Area .. '|' .. tostring(p.createMapPoint(record.ID, record.Area, record.Size)) .. ']]')
end
return tostring(root)
end
function p.createMapPoint(id, text, size)
return mw.html.create('div')
:css({
display = 'inline-flex',
justify_content = 'center',
align_items = 'center',
width = size .. 'px',
height = size .. 'px',
border_radius = '50%',
background_color = 'rgb(255, 255, 255)',
border = '2px solid #000000'
})
:tag('span')
:attr('title', text)
:css({
color = 'rgb(0, 0, 0)',
font_size = '10px',
font_family = "'Helvetica', sans-serif",
font_weight = 'bold'
})
:wikitext(id)
end
return p