(Testing module for infotable bonuses) |
mNo edit summary |
||
Line 29: | Line 29: | ||
none = '' |
none = '' |
||
} |
} |
||
− | local classImage = classImages |
+ | local classImage = classImages[class] |
if classImage == nil then |
if classImage == nil then |
||
classImage = class .. '<br />' |
classImage = class .. '<br />' |
Revision as of 03:49, 24 July 2014
Documentation for this module may be created at Module:Sandbox/doc
-- <nowiki>
--
-- Sandbox module
--
-- To be used to test out ideas in the same way [[RuneScape:Sandbox]] is used
--
local p = {}
local yesno = require( 'Module:Yesno' )
function p.header( frame )
local args = frame:getParent().args
local tbl = mw.html.create( 'table' )
:addClass( 'wikitable' )
:addClass( 'infotableBonuses' )
:css( 'text-align', 'center' )
-- The class corresponds to the class all the items have in common. If they are different, "mixed" will add an additional column to specify it (further down).
local class = args.class or args.type
local classImages = {
melee = '[[File:Attack.png|x34px|link=Melee]]',
ranged = '[[File:Attack.png|x34px|link=Melee]]',
magic = '[[File:Attack.png|x34px|link=Melee]]',
all = '[[File:CombatSwords.png|All]]',
hybrid = '[[File:CombatSwords.png|Hybrid]] Hybrid',
mixed = '',
none = ''
}
local classImage = classImages[class]
if classImage == nil then
classImage = class .. '<br />'
elseif classImage ~= '' then
classImage = classImage .. '<br />'
end
local skill = args.skill
local skill2 = args.skill2
-- define 1st row
local tr1 = tbl:tag('tr')
local th1 = tr1:tag('th')
:attr( 'rowspan', '2' )
:wikitext( classImage .. 'Items' )
if not yesno(args.noinv) then th1:attr( 'colspan', '2' ) end
th1:done()
if class == 'mixed' then
tr1:tag('th')
:attr( 'rowspan', '2' )
:wikitext( 'Type' )
:done()
end
if skill then
tr1:tag('th')
:attr( 'rowspan', '2' )
:wikitext( '{{Skill clickpic|'..skill..'}}<br /><span style="font-size:90%;">Level</span>' )
:done()
end
if skill2 then
tr1:tag('th')
:attr( 'rowspan', '2' )
:wikitext( '{{Skill clickpic|'..skill2..'}}<br /><span style="font-size:90%;">Level</span>' )
:done()
end
local mainSpan = mw.html.create( 'span' )
:css({ ['color'] = '#000' })
:wikitext( 'Mainhand Info' )
:done()
local offSpan = mw.html.create( 'span' )
:css({ ['color'] = '#000' })
:wikitext( 'Off-hand Info' )
:done()
local attrSpan = mw.html.create( 'span' )
:attr( 'title', 'Determines the character\'s endurance determined by their armour rating, life point boost, and prayer bonus' )
:css({ ['color'] = '#000' })
:wikitext( 'Attributes' )
:done()
local critSpan = mw.html.create( 'span' )
:css({ ['color'] = '#000', ['font-size'] = '80%' })
:wikitext( 'Critical Bonuses' )
:done()
tr1:tag('th')
:attr( 'colspan', '3' )
:wikitext( tostring(mainSpan) )
:done()
tr1:tag('th')
:attr( 'colspan', '3' )
:wikitext( '[[Off-hand weapons|' .. tostring(offSpan) .. ']]' )
:done()
tr1:tag('th')
:attr( 'colspan', '3' )
:wikitext( tostring(attrSpan) )
:done()
tr1:tag('th')
:attr( 'colspan', '3' )
:wikitext( '[[Critical hit|' .. tostring(critSpan) ..']]' )
:done()
if args.price then
tr1:tag('th')
:attr( 'rowspan', '2' )
:wikitext( 'Price' )
:done()
end
-- Rarely used anymore, may be a feature worth removing
local image = args.image
if image then
local rowspan = 2 + tonumber(args.rows) + tonumber(args.tot)
local caption = args.caption
tr1:tag('th')
:attr( 'rowspan', rowspan )
:css({['width'] = '125px'})
:wikitext( '[[File:'..image..'|'..caption..']]'..(caption and '<br /><small>'..caption..'</small>' or '') )
:done()
end
-- Not sure if image2 is used at all anymore
local image2 = args.image2
if image2 then
local rowspan = 2 + tonumber(args.rows) + tonumber(args.tot)
local caption2 = args.caption2
tr1:tag('th')
:attr( 'rowspan', rowspan )
:css({['width'] = '125px'})
:wikitext( '[[File:'..image2..'|'..caption2..']]'..(caption2 and '<br /><small>'..caption2..'</small>' or '') )
:done()
end
tr1:done()
-- start 2nd row
local tr2 = tbl:tag('tr')
-- Mainhand stats
tr1:tag('th')
:attr( 'title', 'Mainhand attacking style' )
:wikitext( '[[Attack types|<span style="color:#000">Style</span>]]' )
:done()
tr1:tag('th')
:attr( 'title', 'Mainhand weapon damage' )
:wikitext( 'Dmg' )
:done()
tr1:tag('th')
:attr( 'title', 'Mainhand weapon accuracy' )
:wikitext( 'Acc' )
:done()
-- Off-hand stats
tr1:tag('th')
:attr( 'title', 'Offhand attacking style' )
:wikitext( '[[Attack types|<span style="color:#000">Style</span>]]' )
:done()
tr1:tag('th')
:attr( 'title', 'Offhand weapon damage' )
:wikitext( 'Dmg' )
:done()
tr1:tag('th')
:attr( 'title', 'Offhand weapon accuracy' )
:wikitext( 'Acc' )
:done()
-- Attributes
tr1:tag('th')
:wikitext( '{{Skill clickpic|Defence}}' )
:done()
tr1:tag('th')
:wikitext( '{{Skill clickpic|Constitution}}' )
:done()
tr1:tag('th')
:wikitext( '{{Skill clickpic|Prayer}}' )
:done()
-- Critical Bonuses
tr1:tag('th')
:wikitext( '[[File:Attack-icon.png|20px|link=Melee]]' )
:done()
tr1:tag('th')
:wikitext( '[[File:Ranged-icon.png|20px|link=Ranged]]' )
:done()
tr1:tag('th')
:wikitext( '[[File:Magic-icon.png|20px|link=Magic]]' )
:done()
return tostring(tbl)
end
return p