Module:Construction: Difference between revisions
From Workers & Resources: Soviet Republic Official Wiki
workers-resources-fandom>Letter N (Created page with "local args = {} local p = {} local rownums = {} local constructionPage local function preProcessArgs(frame) local tmp = {} if frame == mw.getCurrentFrame() then tmp = frame:getParent().args else tmp = frame end -- Storage tables local nums = {} -- Loop over all the args for k,v in pairs(tmp) do -- Skip empty args, which are useless if v ~= '' then local cat,num = tostring(k):match('^(%a+)([1-9]%d*)$') if cat == 'header' or cat == 'list' then...") |
m (12 revisions imported) |
||
(13 intermediate revisions by 2 users not shown) | |||
Line 43: | Line 43: | ||
for _, v in ipairs(rownums) do | for _, v in ipairs(rownums) do | ||
if args['list'..v] then | if args['list'..v] then | ||
bobby_tables:wikitext('<tr><th>'..args['title'..v]..'</tr></th>') | if v > 1 then | ||
bobby_tables:wikitext('<tr>< | bobby_tables:wikitext('<tr><th style="border-top: solid 2px black;">'..args['title'..v]..'</th></tr>') | ||
else | |||
bobby_tables:wikitext('<tr><th>'..args['title'..v]..'</th></tr>') | |||
end | |||
bobby_tables:wikitext('<tr><td>'..args['list'..v]..'</td></tr>') | |||
end | end | ||
end | end | ||
constructionPage:wikitext( | -- OLD: eedfce (also picked but i used gimp on the actual image file) | ||
constructionPage:wikitext( | |||
'{|style="border-radius:3px; background-color: #ECE2D8; color:black; box-shadow: 0 0 0 black, 0 0 1.5em #8a4d0f inset;"'.. | |||
'\n|<div style="background-color: #4a1010f2; color: #eee; margin: 3px 0px; padding: 3px;"><big><b>Construction</b></big></div>'.. | |||
'\n'..tostring(bobby_tables).. | |||
'\n|}') | |||
return tostring(constructionPage) | return tostring(constructionPage) | ||
end | end |
Latest revision as of 18:43, 14 June 2024
Documentation for this module may be created at Module:Construction/doc
local args = {} local p = {} local rownums = {} local constructionPage local function preProcessArgs(frame) local tmp = {} if frame == mw.getCurrentFrame() then tmp = frame:getParent().args else tmp = frame end -- Storage tables local nums = {} -- Loop over all the args for k,v in pairs(tmp) do -- Skip empty args, which are useless if v ~= '' then local cat,num = tostring(k):match('^(%a+)([1-9]%d*)$') if cat == 'header' or cat == 'list' then nums[num] = true end args[k] = v -- Simple copy end end for k, v in pairs(nums) do rownums[#rownums+1] = tonumber(k) end table.sort(rownums) end function _construction() constructionPage = mw.html.create('') local bobby_tables = mw.html.create('table') for _, v in ipairs(rownums) do if args['list'..v] then if v > 1 then bobby_tables:wikitext('<tr><th style="border-top: solid 2px black;">'..args['title'..v]..'</th></tr>') else bobby_tables:wikitext('<tr><th>'..args['title'..v]..'</th></tr>') end bobby_tables:wikitext('<tr><td>'..args['list'..v]..'</td></tr>') end end -- OLD: eedfce (also picked but i used gimp on the actual image file) constructionPage:wikitext( '{|style="border-radius:3px; background-color: #ECE2D8; color:black; box-shadow: 0 0 0 black, 0 0 1.5em #8a4d0f inset;"'.. '\n|<div style="background-color: #4a1010f2; color: #eee; margin: 3px 0px; padding: 3px;"><big><b>Construction</b></big></div>'.. '\n'..tostring(bobby_tables).. '\n|}') return tostring(constructionPage) end function p.main(frame) preProcessArgs(frame) return _construction() end return p