[Module] RL-Dice

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
Codex
Party member
Posts: 106
Joined: Tue Mar 06, 2012 6:49 am

[Module] RL-Dice

Post by Codex » Fri Aug 09, 2013 10:58 pm

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.

:megagrin:

PS - Still not used to github, it's very weird. hahahah
Last edited by Codex on Mon Jun 27, 2016 3:16 pm, edited 1 time in total.

User avatar
Codex
Party member
Posts: 106
Joined: Tue Mar 06, 2012 6:49 am

Re: [Module] RL-Dice

Post by Codex » Tue Dec 31, 2013 9:43 pm

New update! :awesome:
  • 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]

User avatar
Codex
Party member
Posts: 106
Joined: Tue Mar 06, 2012 6:49 am

Re: [Module] RL-Dice

Post by Codex » Wed Apr 30, 2014 6:35 pm

Another major update!
  • 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. :monocle:

User avatar
Codex
Party member
Posts: 106
Joined: Tue Mar 06, 2012 6:49 am

Re: [Module] RL-Dice

Post by Codex » Mon Jun 27, 2016 3:14 pm

Final Version Released!
  • 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
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. :ultrahappy:

User avatar
Ulydev
Party member
Posts: 445
Joined: Mon Nov 10, 2014 10:46 pm
Location: Paris
Contact:

Re: [Module] RL-Dice

Post by Ulydev » Mon Jun 27, 2016 3:17 pm

Wow. Congratulations for finishing this project after 3 years. A lot of people, including me, would have let it die.

User avatar
Pangit
Party member
Posts: 148
Joined: Thu Jun 16, 2016 9:20 am

Re: [Module] RL-Dice

Post by Pangit » Tue Jun 28, 2016 1:21 am

Thanks for all your hard work, I found this really useful.

User avatar
Codex
Party member
Posts: 106
Joined: Tue Mar 06, 2012 6:49 am

Re: [Module] RL-Dice

Post by Codex » Fri Jul 01, 2016 12:42 am

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!!!

User avatar
Codex
Party member
Posts: 106
Joined: Tue Mar 06, 2012 6:49 am

Re: [Module] RL-Dice

Post by Codex » Mon Oct 31, 2016 11:46 pm

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
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.

Post Reply

Who is online

Users browsing this forum: Conifer and 29 guests