Just tossing a Roguelike oriented dice library out here. It's on github here - https://github.com/timothymtorres/RL-Dice
Any comments/feedback is appreciated! Also new features can be requested, but for now there are none I can think to add.
PS - Still not used to github, it's very weird. hahahah
[Module] RL-Dice
[Module] RL-Dice
Last edited by Codex on Mon Jun 27, 2016 3:16 pm, edited 1 time in total.
Re: [Module] RL-Dice
New update!
- New method getString, input dice arguments to return a formatted dice string.
- New method getDice, input dice string to return a formatted dice table.
- Updated method roll, can now use a dice string, number, or table to roll dice.
- Localized methods: determine and shuffle
- Dice.roll now returns table array with dice rolls starting at [1]
Re: [Module] RL-Dice
Another major update!
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.
- 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)
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.
Re: [Module] RL-Dice
Final Version Released!
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.
- Added dice sets
- Added dice minimums
- 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
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.
Re: [Module] RL-Dice
Wow. Congratulations for finishing this project after 3 years. A lot of people, including me, would have let it die.
Re: [Module] RL-Dice
Thanks for all your hard work, I found this really useful.
Re: [Module] RL-Dice
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!
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!
Great! I'm glad there are people finding it helpful!!!Pangit wrote:Thanks for all your hard work, I found this really useful.
Re: [Module] RL-Dice
More News
- Major bug fixed that made all rerolls and bonuses positive regardless if they were negative.
- RL-Dice added to rotLove. You can call it from the rot library using ROT.Dice
- API docs created thanks to LDoc
Who is online
Users browsing this forum: SiENcE and 0 guests