1,043
edits
(turns out these values also need to be rounded for character stats... tried making a few adjustments.) |
(oops, pcall no longer necessary) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
function DiceFormat.diceStats(frame) | function DiceFormat.diceStats(frame) | ||
local | local dice = Dice.parse(frame.args.roll) | ||
local template_title = (frame.args.template ~= nil and frame.args.template ~= '') and frame.args.template or 'Dice string' | local template_title = (frame.args.template ~= nil and frame.args.template ~= '') and frame.args.template or 'Dice string' | ||
local mult = (frame.args.multiplier ~= nil and frame.args.multiplier ~= '') and frame.args.multiplier or 1 | local mult = (frame.args.multiplier ~= nil and frame.args.multiplier ~= '') and frame.args.multiplier or 1 | ||
local extra_afterroll = (frame.args.extraafterroll ~= nil and frame.args.extraafterroll ~= '') and frame.args.extraafterroll or 0 | |||
local average = dice:average() * mult | local average = dice:average() * mult + extra_afterroll | ||
local average_truncated = ('%d'):format(average) | local average_truncated = ('%d'):format(average) | ||
local maximum = dice:maximum() * mult | local maximum = dice:maximum() * mult + extra_afterroll | ||
local minimum = dice:minimum() * mult | local minimum = dice:minimum() * mult + extra_afterroll | ||
local range = dice:range() * mult | local range = dice:range() * mult | ||
local variance = dice:variance() * mult | local variance = dice:variance() * mult |