Module:Dice/Format: Difference between revisions
Jump to navigation
Jump to search
m (declare local) |
m (DiceStats -> DiceFormat) |
||
Line 1: | Line 1: | ||
local Dice = require'Module:Dice' | local Dice = require'Module:Dice' | ||
local | local DiceFormat = {} | ||
function | function DiceFormat.diceStats(frame) | ||
local dice = Dice.fromString(frame.args.roll) | local dice = Dice.fromString(frame.args.roll) | ||
local templatetitle | local templatetitle | ||
Line 22: | Line 22: | ||
end | end | ||
return | return DiceFormat |
Revision as of 23:18, 31 July 2019
local Dice = require'Module:Dice'
local DiceFormat = {}
function DiceFormat.diceStats(frame)
local dice = Dice.fromString(frame.args.roll)
local templatetitle
if (frame.args.template ~= nil and frame.args.template ~= '') then
templatetitle = frame.args.template
else
templatetitle = 'Dice string'
end
return frame:expandTemplate{
title = templatetitle,
args = {
minimum = dice:minimum(),
mean = dice:mean(),
maximum = dice:maximum(),
},
}
end
return DiceFormat