Module:Sandbox: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 14: | Line 14: | ||
function p._main(args) | function p._main(args) | ||
local container = mw.html.create('div') | |||
local group | local group | ||
local function newGroup(extraClasses) | local function newGroup(extraClasses) | ||
Line 147: | Line 147: | ||
if args.effect then | if args.effect then | ||
group = newGroup('textwrap') | group = newGroup('textwrap') | ||
:node( newLine() | :node( newLine('text-mod') | ||
: | :wikitext(args.effect) | ||
) | ) | ||
container:node(group) | container:node(group) | ||
Line 192: | Line 192: | ||
if args.effect then | if args.effect then | ||
group | group | ||
:node( newLine() | :node( newLine('text-mod') | ||
: | :wikitext(args.effect) | ||
) | ) | ||
end | end | ||
Line 214: | Line 214: | ||
end | end | ||
group = newGroup('textwrap') | group = newGroup('textwrap') | ||
:node( newLine('text-mod') | |||
:wikitext(args.effect) | |||
) | |||
container:node(group) | |||
end | |||
if args.level or args.strength or args.dexterity or args.intelligence then | |||
local lvlReq | |||
local strReq | |||
local dexReq | |||
local intReq | |||
local reqTxt | |||
if args.level then | |||
lvlReq = 'Level ' .. tostring( newColor('value', args.level) ) | |||
end | |||
if args.strength then | |||
reqTxt = 'Strength' | |||
if args.level or args.dexterity or args.intelligence then | |||
reqTxt = 'Str' | |||
end | |||
strReq = tostring( newColor('value', args.strength) ) .. reqTxt | |||
end | |||
if args.dexterity then | |||
reqTxt = 'Dexterity' | |||
if args.level or args.strength or args.intelligence then | |||
reqTxt = 'Dex' | |||
end | |||
dexReq = tostring( newColor('value', args.dexterity) ) .. reqTxt | |||
end | |||
if args.intelligence then | |||
reqTxt = 'Intelligence' | |||
if args.level or args.strength or args.dexterity then | |||
reqTxt = 'Int' | |||
end | |||
intReq = tostring( newColor('value', args.intelligence) ) .. reqTxt | |||
end | |||
if not doConcat then | |||
doConcat = require('Module:Concat')._main | |||
end | |||
group = newGroup() | |||
:node( newLine() | :node( newLine() | ||
:node( | :wikitext('Requires ') | ||
:wikitext( | |||
doConcat({lvlReq, strReq, dexReq, intReq}) | |||
) | |||
) | |||
container:node(group) | |||
end | |||
if args.implicitMods then | |||
group = newGroup() | |||
:node( newLine('text-mod') | |||
:wikitext(args.implicitMods) | |||
) | |||
container:node(group) | |||
end | |||
if args.randomMods then | |||
group = newGroup() | |||
:node( newLine('text-mod') | |||
:wikitext(args.randomMods) | |||
) | |||
container:node(group) | |||
end | |||
if args.cosmeticMods then | |||
group = newGroup() | |||
:node( newLine('text-cosmetic') | |||
:wikitext(args.cosmeticMods) | |||
) | |||
container:node(group) | |||
end | |||
if args.flavourText then | |||
group = newGroup() | |||
:node( newLine('textwrap text-flavour') | |||
:wikitext(args.flavourText) | |||
) | |||
container:node(group) | |||
end | |||
if args.helpText then | |||
group = newGroup() | |||
:node( newLine('textwrap text-help') | |||
:wikitext(args.helpText) | |||
) | ) | ||
container:node(group) | container:node(group) |
Revision as of 04:56, 22 April 2015
This page is not an actual Scribunto module. It exists to provide editors a place to create experimental modules.
Naming your modules
To keep things tidy, please use the following format to name your experimental modules:
Module:Sandbox/Your username/Module name
Cleaning up unused modules
Experimental modules may be deleted by admins upon request or after a long period of inactivity.
List of modules in this area
For a list of the experimental modules under Module:Sandbox, see Special:PrefixIndex/Module:Sandbox/.
The above documentation is transcluded from Module:Sandbox/doc.
Editors can experiment in this module's sandbox and testcases pages.
Subpages of this module.
Editors can experiment in this module's sandbox and testcases pages.
Subpages of this module.
local p = {}
local getArgs
function p.main(frame)
if not getArgs then
getArgs = require('Module:Arguments').getArgs
end
local args = getArgs(frame, {
wrappers = 'Template:Sandbox',
trim = false
})
return p._main(args)
end
function p._main(args)
local container = mw.html.create('div')
local group
local function newGroup(extraClasses)
extraClasses = extraClasses or ''
return mw.html.create('span')
:attr('class', 'itemboxstatsgroup ' .. extraClasses)
end
local function newLine(extraClasses)
extraClasses = extraClasses or ''
return mw.html.create('span')
:attr('class', 'itemboxstatsgroupline ' .. extraClasses)
end
local function newColor(label, text)
if text == nil or text == '' then
return nil
end
return mw.html.create('span')
:attr('class', 'text-' .. label)
:wikitext(text)
end
args.type = string.lower(args.type)
if args.type == 'weapon' then
group = newGroup()
:node( newLine()
:wikitext(args.subtype)
)
if args.physical then
group
:node( newLine()
:wikitext('Physical Damage: ')
:node( newColor('value', args.physical) )
)
end
if args.fire or args.cold or args.lightning then
if not doConcat then
doConcat = require('Module:Concat')._main
end
group
:node( newLine()
:wikitext('Elemental Damage: ')
:wikitext(
doConcat({
tostring( newColor('fire', args.fire) ),
tostring( newColor('cold', args.cold) ),
tostring( newColor('lightning', args.lightning) )
})
)
)
end
if args.chaos then
group
:node( newLine()
:wikitext('Chaos Damage: ')
:node( newColor('chaos', args.chaos) )
)
end
group
:node( newLine()
:wikitext('Critical Strike Chance: ')
:node( newColor('value', args.critChance) )
)
:node( newLine()
:wikitext('Attacks per Second: ')
:node( newColor('value', args.attacksPerSecond) )
)
container:node(group)
elseif args.type == 'armour' then
if args.blockChance or args.armour or args.evasion or args.energyShield then
group = newGroup()
if args.blockChance then
group
:node( newLine()
:wikitext('Chance to Block: ')
:node( newColor('value', args.blockChance) )
)
end
if args.armour then
group
:node( newLine()
:wikitext('Armour: ')
:node( newColor('value', args.armour) )
)
end
if args.evasion then
group
:node( newLine()
:wikitext('Evasion: ')
:node( newColor('value', args.evasion) )
)
end
if args.energyShield then
group
:node( newLine()
:wikitext('Energy Shield: ')
:node( newColor('value', args.energyShield) )
)
end
container:node(group)
end
elseif args.type == 'map' then
if args.mapLevel then
group = newGroup()
:node( newLine()
:wikitext('Map Level: ')
:node( newColor('value', args.mapLevel) )
)
if args.itemQuantity then
group
:node( newLine()
:wikitext('Item Quantity: ')
:node( newColor('value', args.itemQuantity) )
)
end
container:node(group)
end
elseif args.type == 'jewel' then
if args.radius then
group = newGroup()
:node( newLine()
:wikitext('Radius: ')
:node( newColor('value', args.radius) )
)
container:node(group)
end
elseif args.type == 'currency' then
group = newGroup()
:node( newLine()
:wikitext('Stack Size: ')
:node( newColor('value', args.stackSize) )
)
container:node(group)
if args.effect then
group = newGroup('textwrap')
:node( newLine('text-mod')
:wikitext(args.effect)
)
container:node(group)
end
elseif args.type == 'flask' then
group = newGroup()
if args.life then
group
:node( newLine()
:wikitext('Recovers ')
:node( newColor('value', args.life) )
:wikitext(' Life over ')
:node( newColor('value', args.duration) )
:wikitext(' Seconds')
)
end
if args.mana then
group
:node( newLine()
:wikitext('Recovers ')
:node( newColor('value', args.mana) )
:wikitext(' Mana over ')
:node( newColor('value', args.duration) )
:wikitext(' Seconds')
)
end
if args.effect then
group
:node( newLine()
:wikitext('Lasts ')
:node( newColor('value', args.duration) )
:wikitext(' Seconds')
)
end
group
:node( newLine()
:wikitext('Consumes ')
:node( newColor('value', args.chargeUse) )
:wikitext(' of ')
:node( newColor('value', args.chargeCap) )
:wikitext(' Charges on use')
)
if args.effect then
group
:node( newLine('text-mod')
:wikitext(args.effect)
)
end
container:node(group)
elseif args.type == 'microtrans' then
group = newGroup()
if args.subtype or args.stackSize then
group
:node( newLine()
:wikitext(args.subtype)
)
if args.stackSize then
group
:node( newLine()
:wikitext('Stack Size: ')
:node( newColor('value', args.stackSize) )
)
end
container:node(group)
end
group = newGroup('textwrap')
:node( newLine('text-mod')
:wikitext(args.effect)
)
container:node(group)
end
if args.level or args.strength or args.dexterity or args.intelligence then
local lvlReq
local strReq
local dexReq
local intReq
local reqTxt
if args.level then
lvlReq = 'Level ' .. tostring( newColor('value', args.level) )
end
if args.strength then
reqTxt = 'Strength'
if args.level or args.dexterity or args.intelligence then
reqTxt = 'Str'
end
strReq = tostring( newColor('value', args.strength) ) .. reqTxt
end
if args.dexterity then
reqTxt = 'Dexterity'
if args.level or args.strength or args.intelligence then
reqTxt = 'Dex'
end
dexReq = tostring( newColor('value', args.dexterity) ) .. reqTxt
end
if args.intelligence then
reqTxt = 'Intelligence'
if args.level or args.strength or args.dexterity then
reqTxt = 'Int'
end
intReq = tostring( newColor('value', args.intelligence) ) .. reqTxt
end
if not doConcat then
doConcat = require('Module:Concat')._main
end
group = newGroup()
:node( newLine()
:wikitext('Requires ')
:wikitext(
doConcat({lvlReq, strReq, dexReq, intReq})
)
)
container:node(group)
end
if args.implicitMods then
group = newGroup()
:node( newLine('text-mod')
:wikitext(args.implicitMods)
)
container:node(group)
end
if args.randomMods then
group = newGroup()
:node( newLine('text-mod')
:wikitext(args.randomMods)
)
container:node(group)
end
if args.cosmeticMods then
group = newGroup()
:node( newLine('text-cosmetic')
:wikitext(args.cosmeticMods)
)
container:node(group)
end
if args.flavourText then
group = newGroup()
:node( newLine('textwrap text-flavour')
:wikitext(args.flavourText)
)
container:node(group)
end
if args.helpText then
group = newGroup()
:node( newLine('textwrap text-help')
:wikitext(args.helpText)
)
container:node(group)
end
return tostring(container)
end
return p