More actions
No edit summary |
No edit summary |
||
Line 16: | Line 16: | ||
header_row:tag('th'):wikitext('Color') | header_row:tag('th'):wikitext('Color') | ||
header_row:tag('th'):wikitext('Difficulty') | header_row:tag('th'):wikitext('Difficulty') | ||
header_row:tag('th'):wikitext(' | header_row:tag('th'):wikitext('Stages') | ||
header_row:tag('th'):wikitext('Badge') | header_row:tag('th'):wikitext('Badge') | ||
Line 44: | Line 44: | ||
local stage_cell = row:tag('td') | local stage_cell = row:tag('td') | ||
local start_value = args[difficulty_param_name .. '_start'] | |||
local end_value = args[difficulty_param_name .. '_end'] | |||
stage_cell:wikitext(' | stage_cell:wikitext( (start_value or '??') .. ' - ' .. (end_value or '??')) | ||
local badge_cell = row:tag('td') | local badge_cell = row:tag('td') | ||
Line 55: | Line 57: | ||
-- :attr('target', '_blank') | -- :attr('target', '_blank') | ||
badge_cell:wikitext('[[File:Icons Badge Small White.png|link=https://roblox.com/badges/' .. badge_value .. '/obbywikidifficultylink|alt=Badge|28px]]') | badge_cell:wikitext('[[File:Icons Badge Small White.png|link=https://roblox.com/badges/' .. badge_value .. '/obbywikidifficultylink|alt=Badge|28px]]') | ||
badge_cell:attr('style', 'vertical-align: middle; margin-auto;') | |||
-- :attr('src', mw.file.makeUrl('Icons Badge Small White.png')) | -- :attr('src', mw.file.makeUrl('Icons Badge Small White.png')) | ||
-- :attr('alt', 'Badge') | -- :attr('alt', 'Badge') |
Revision as of 10:45, 7 April 2025
Documentation for this module may be created at Module:Difficulties/doc
local p = {}
local config = require('Module:Difficulties/config')
local function ucfirst(str)
return str:sub(1,1):upper() .. str:sub(2)
end
function p.main(frame)
local args = frame:getParent().args
local difficulties = config.difficulties
local output = mw.html.create('table')
output:addClass('wikitable')
local header_row = output:tag('tr')
header_row:tag('th'):wikitext('Color')
header_row:tag('th'):wikitext('Difficulty')
header_row:tag('th'):wikitext('Stages')
header_row:tag('th'):wikitext('Badge')
for i, v in pairs(difficulties) do
local difficulty_param_name = mw.text.trim(i)
local enabled_param = args[ucfirst(difficulty_param_name)] or args[difficulty_param_name]
if enabled_param and mw.text.trim(enabled_param):lower() == 'true' then
local row = output:tag('tr')
local icon_cell = row:tag('td')
-- if v.file then
icon_cell:tag('div')
:attr('style', 'width: 20px; height: 20px; background-color: ' .. v.color .. '; vertical-align: middle;')
local name_cell = row:tag('td')
local page_link = config.meta.page_prefix .. v.display
if not v.display then
page_link = config.meta.page_prefix .. ucfirst(i)
end
-- name_cell:tag('a')
name_cell:wikitext('[[' .. v.display .. ']]') -- maybe thats how this works
-- :wikitext('[[' .. v.display .. ']]')
-- :attr('href', mw.title.makeTitle('',page_link):fullUrl())
-- :wikitext(v.display or ucfirst(i))
local stage_cell = row:tag('td')
local start_value = args[difficulty_param_name .. '_start']
local end_value = args[difficulty_param_name .. '_end']
stage_cell:wikitext( (start_value or '??') .. ' - ' .. (end_value or '??'))
local badge_cell = row:tag('td')
local badge_param_name = difficulty_param_name .. '_badge'
local badge_value = args[badge_param_name]
if badge_value then
-- badge_cell:tag('a')
-- :attr('href', 'https://roblox.com/badges' .. badge_value)
-- :attr('target', '_blank')
badge_cell:wikitext('[[File:Icons Badge Small White.png|link=https://roblox.com/badges/' .. badge_value .. '/obbywikidifficultylink|alt=Badge|28px]]')
badge_cell:attr('style', 'vertical-align: middle; margin-auto;')
-- :attr('src', mw.file.makeUrl('Icons Badge Small White.png'))
-- :attr('alt', 'Badge')
-- :attr('style', 'width: 20px; height: 20px; vertical-align: middle;')
else
badge_cell:wikitext(' ')
end
end
end
return tostring(output)
end
return p