Can now reroll all dice with ^++ or ^-- (similar to all bonus)
Metamethods and Classes!!!
Dice_odds module included (can even give the probability for rerolls and bonus)
Hopefully a few people find this library useful. I think as far as development goes, it's finished. There are two things I need to nit-pick in regards to features though.
The first being that with a negative dice bonus, it is possible to return a negative roll. This doesn't seem like it should be correct IMO. I was tempted to default a negative roll into 0 or 1 in case it happens, but what if people needed to keep track of the negative roll?! Soooo I'm unsure how to handle this and think it might just to be best to leave it how it is...
My other issue is with classes. This is my first time actually implementing metatables from scratch. I've usually used middleclass for my other projects, but for a library this small it seemed like it would be redundant to include it. So using my limited knowledge of OO programming for lua, I did my best to add inheritance. Hopefully, it works out correctly.
Optimization - many of the default library functions (ie. math.random,
math.max) were set as locals to speed things up
Changed dice:roll() no longer returns a table! Instead it return
value(s) depending on how many dice sets there are. If you want tables
just use {Dice:roll()} to put the results in a table
Changed string.match for the dice string to check for a SPECIFIC
pattern. If dice does not match pattern EXACTLY it will cause an error.
Removed dice.odds
The minimums are so that the dice don't roll into a negative number or 0, unless the user desires it to (in which case set it to nil) The default minimum is set in the library as 1 which can changed easily.
Calculating the odds with rerolls requires some kind of formula that I couldn't figure out so I was brute forcing the combinations to get the %'s. With a big enough dice and rerolls this would have been slow as a slug so I made the decision to deprecate this feature.
Other than a few bug fixes or typos [if they appear], this module is now considered fully completed. Hope you guys enjoy! If anyone decides to implement this in their game let me know, I'd love to check it out.
I worked on this project in spurts, so it didn't progress continuously the entire three years. Yet, I'm glad it's finally reached a finishing point where there are no further features I can think of to add without bloating the module unnecessarily.
If anyone is trying to make a roguelike I would say RL-Dice combined with https://love2d.org/wiki/RotLove would be an excellent one-two combo!
Pangit wrote:Thanks for all your hard work, I found this really useful.
Great! I'm glad there are people finding it helpful!!!
I am considering adding a cache ability for the dice. It probably won't be for a few months until I start working on it, but it should speed things up and help use less memory. This is going to be more of an optimization and less of a functional feature, though so the dice will remain the same.