Module:AreaMapDisplay: Difference between revisions
From IdleOn MMO Wiki
(Created page with "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...") |
mNo edit summary |
||
Line 58: | Line 58: | ||
z_index = 2 | z_index = 2 | ||
}) | }) | ||
:wikitext('[[Worlds#' .. record.Area .. '|' .. p.createMapPoint(record.ID, record.Area, record.Size) .. ']]') | :wikitext('[[Worlds#' .. record.Area .. '|' .. p.createMapPoint(record.ID, record.Area, record.Size) .. ']]') | ||
end | end | ||
Line 65: | Line 65: | ||
function p.createMapPoint(id, text, size) | function p.createMapPoint(id, text, size) | ||
local point = mw.html.create('div') | |||
:css({ | :css({ | ||
display = 'inline-flex', | display = 'inline-flex', | ||
Line 85: | Line 85: | ||
}) | }) | ||
:wikitext(id) | :wikitext(id) | ||
return tostring(point) | |||
end | end | ||
return p | return p |
Revision as of 16:44, 24 July 2024
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 .. '|' .. p.createMapPoint(record.ID, record.Area, record.Size) .. ']]')
end
return tostring(root)
end
function p.createMapPoint(id, text, size)
local point = 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)
return tostring(point)
end
return p