Module:ActionCombo
Jump to navigation
Jump to search
Documentation for this module may be created at Module:ActionCombo/doc
local p = {}
function p.main(frame)
if frame == mw.getCurrentFrame() then
args = require('Module:ProcessArgs').merge(true)
else
frame = mw.getCurrentFrame()
end
-- create the base html holder
local html = mw.html.create()
html:tag('dl'):tag('dd')
local table = html:tag('table')
:cssText('border-collapse: collapse; border-color: transparent; white-space: initial; line-height: normal')
local headerRow = table:tag('tr')
:attr({ align = 'center', bgcolor = '#121212' })
:cssText('border-color: transparent; white-space: nowrap; line-height: 2em; font-size:85%')
local header = headerRow:tag('th')
:attr({ colspan='6', align='left', height='28em' })
:cssText('color: #ffff99; padding-left: 0.7em; font-size:117%; border-color: transparent')
:wikitext(args.name or 'Skill Combo')
headerRow:done()
-- iterate all unnamed arguments of the frame by using ipairs(args) and storing into a table
-- this allows us to define an unlimited number of actions, without having to worry about how many there are.
local iArgs = {}
for k, v in ipairs(args) do
iArgs[k] = v
end
if (#iArgs < 1) then
-- there were no unnamed arguments, probably using legacy "action1,action2" method.
for i = 1, 15, 1 do
local key = 'action' .. i
if (args[key] ~= nil) then
iArgs[i] = args[key]
end
end
end
local contentText = ''
-- iterate over our ipairs (args) table
for i = 1, #iArgs, 1 do
if (i > 1) then
contentText = contentText .. " '''>''' "
end
local action = iArgs[i]
contentText = contentText .. '[[File:' .. action .. '.png|50px|link=' .. action .. ']]'
end
local actionsRow = table:tag('tr')
local actionsCell = actionsRow:tag('td')
:attr({valign='top', bgcolor='#050505', colspan='1'})
:cssText('color:white; border-color: transparent')
:wikitext(frame:preprocess(contentText))
html:done()
return html
end
function round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end
function split(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={}
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
table.insert(t, str)
end
return t
end
return p