I've found out we're implementing something starting from the same source. I would love to hear your thoughts about how to implement "custom" behavior/asymmetry, such as the "critical hits" example.
Do you think that adding a way to pass in user defined functions could be beneficial? Since it's something that usually would affect the final result that way might be usless/reduntant/code bloating?
Something like that could be as the following code
-- dice module
function roll(dice, callback)
result =math.random(dice)
returncallback(dice, result)
end-- user
dm =require('dicemodule')
doubleup =function (dice, result)
value = result
if (result == dice) then value = result *2endreturn value
end
dm.roll(6, doubleup)
Thanks for your attention and the effort on this module!
For instance, if I were creating a puzzle game or a roguelike where each level is randomly generated, it would be useful to be able to be able to store the random seed and know that the same seed will always generate the same level. I imagine this as a parallel set of functions exactly like the current ones, adding an extra parameter for the RNG callback function.