Advertisement:

Author Topic: Dice Roller  (Read 43128 times)

Online Colin

  • Customizer
  • SMF Hero
  • *
  • Posts: 6,744
  • Gender: Male
  • SMF Customizer
    • colinschoen on GitHub
Dice Roller
« on: July 30, 2009, 09:52:06 PM »
Link to Mod

This mod allows users to roll dice. They can use the preview function to preview dice rolls to make sure they have it right for what they want, but once they press Post, the dice rolls are embedded in the post, meaning that the only way they can change is if the post is edited, but a warning is issued if that is attempted.

It starts from a [roll] tag, and outputs a [blockquote] tag (implemented just for the mod) - trying to use the blockquote tag outside of [roll] circumstances (such as quoting the post, or better, editing the post) generates a visible warning.

There are a variety of options you can have inside the roll tag:

[roll]1d6[/roll] - rolls 1 6-sided dice.
Might result in:
Quote
Rolled 1d6 : 2, total 2

[roll]2d12+5[/roll] - roll 2 12-sided dice and add 5 to the result
Might result in:
Quote
Rolled 2d12+5 : 6, 11 + 5, total 22

[roll]2d20^10[/roll] - roll 2 20-sided dice, re-rolling any result necessary so that the dice rolls are greater than 10.
Quote
Rolled 2d20^10 : 3 8 10 3 17, 2 10 9 10 14, total 31

[roll]2d20v10[/roll] - roll 2 20-sided dice, re-rolling any result necessary so that the dice rolls are less than 10.
Quote
Rolled 2d20v10 : 11 3, 3, total 6

[roll]2d20<10[/roll] - roll 2 20-sided dice, discarding any result where the roll was not less than 10.
Quote
Rolled 2d20<10 : 4, 20, total 4

[roll]2d20>10[/roll] - roll 2 20-sided dice, discarding any result where the roll was not greater than 10.
Quote
Rolled 2d20>10 : 9, 10

Normally it will add the word 'Rolled' in front - you can customise this. For example, a spell that does some serious damage in a game:
[roll]{Freezing} 1d10 {Fire} 1d20[/roll]
Quote
Freezing 1d10 : 1, total 1
Fire 1d20 : 2, total 2

You can also nest the requirements, with the proviso of stating the things as they are in order here.
[roll]{Uberdamage} 15d100+10^10v90<80>20[/roll] - 15 100-sided dice, adding 10 to the result, rerolling anything 10 or less, rerolling anything 90 or higher, and if after that, you have values 20 or less, or 80 or higher, they get dropped.
Quote
Uberdamage 15d100+10^10v90<80>20 : 82, 7 61, 3 36, 59, 30, 86, 14, 42, 70, 22, 99 58, 100 73, 46, 93 1 91 42, 12 + 10, total 549

Lastly you can also have an iterator at the end:
[roll]2d6x3[/roll] - roll 2d6 3 times and display the results overall
Quote
Rolled 2d6 : 6, 3, total 9
Rolled 2d6 : 1, 4, total 5
Rolled 2d6 : 1, 5, total 6


BBcode is not supported anywhere inside the [roll] tag.

Note I haven't provided a help file in the script, but generally this is going to be of limited use and for the forums it will be useful, they will likely want to explain it better to their users anyway.

(There is, as of 1.3, a button to click as well as RC2 support)

There are also limitations to prevent abuse; the most dice that can be used at once is 20, and the highest value of dice is 1000-sided.
« Last Edit: July 13, 2013, 10:36:06 PM by Colin »
"If everybody is thinking alike, then somebody is not thinking." - Gen. George S. Patton Jr.

Offline Joe N

  • Sr. Member
  • ****
  • Posts: 815
  • Gender: Male
  • Need An Avatar Pack? Send Me A PM!
    • The Chill Band Forum
Re: Dice Roller
« Reply #1 on: July 31, 2009, 07:49:07 AM »
Screenshot>
Microsoft: "We Need to Imagine Life Without Walls."
I Say: "If There are No Walls Who needs Windows."



My Mods (6) All My Mods Updated To SMF 2.0 RC2 and SMF 1.1.10!


Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 63,571
Re: Dice Roller
« Reply #2 on: July 31, 2009, 08:00:10 AM »
Though it looks virtually identical to the post above, I have added screenshots to the mod page for you, one showing the building of the [roll] tag, and one showing its output.
And his eyes have all the seeming of a demon's that is dreaming,
And the lamp-light o'er him streaming throws his shadow on the floor

Offline Joe N

  • Sr. Member
  • ****
  • Posts: 815
  • Gender: Male
  • Need An Avatar Pack? Send Me A PM!
    • The Chill Band Forum
Re: Dice Roller
« Reply #3 on: July 31, 2009, 08:09:59 AM »
Though it looks virtually identical to the post above, I have added screenshots to the mod page for you, one showing the building of the [roll] tag, and one showing its output.

Thank You
Microsoft: "We Need to Imagine Life Without Walls."
I Say: "If There are No Walls Who needs Windows."



My Mods (6) All My Mods Updated To SMF 2.0 RC2 and SMF 1.1.10!


Offline aaraon

  • Semi-Newbie
  • *
  • Posts: 52
  • Gender: Male
    • Fale RPG
Re: Dice Roller
« Reply #4 on: August 04, 2009, 07:27:50 PM »
I've tried to install this mod but it don't modify the "subs.php" file.
 ./Sources/Subs.php Fail

Someone else knows why?


Sorry for my english.
[]´s

Aaraon Thomas

www.falerpg.com.br

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 63,571
Re: Dice Roller
« Reply #5 on: August 04, 2009, 07:37:26 PM »
Is this 1.1 or 2.0?
And his eyes have all the seeming of a demon's that is dreaming,
And the lamp-light o'er him streaming throws his shadow on the floor

Offline aaraon

  • Semi-Newbie
  • *
  • Posts: 52
  • Gender: Male
    • Fale RPG
Re: Dice Roller
« Reply #6 on: August 04, 2009, 08:03:56 PM »
Oh, sorry. My forum is the 1.10 version

Here the adress
http://www.falerpg.com.br/forum/
[]´s

Aaraon Thomas

www.falerpg.com.br

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 63,571
Re: Dice Roller
« Reply #7 on: August 04, 2009, 09:24:08 PM »
That's two reports from 1.1.10 I've had. I need to investigate this further. Will reply shortly.
And his eyes have all the seeming of a demon's that is dreaming,
And the lamp-light o'er him streaming throws his shadow on the floor

Offline aaraon

  • Semi-Newbie
  • *
  • Posts: 52
  • Gender: Male
    • Fale RPG
Re: Dice Roller
« Reply #8 on: August 05, 2009, 10:14:56 AM »
Thanks, I will be waiting. :-)
[]´s

Aaraon Thomas

www.falerpg.com.br

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 63,571
Re: Dice Roller
« Reply #9 on: August 06, 2009, 10:44:43 PM »
Should be fixed now for 1.1.10.

Not bumping the version number, it's not a code change. It just changes how it finds where to insert something - users who've installed it successfully don't have to worry, but future users will be all good.
And his eyes have all the seeming of a demon's that is dreaming,
And the lamp-light o'er him streaming throws his shadow on the floor

Offline aaraon

  • Semi-Newbie
  • *
  • Posts: 52
  • Gender: Male
    • Fale RPG
Re: Dice Roller
« Reply #10 on: August 07, 2009, 10:36:54 AM »
Sorry, same error mensage! :-(
[]´s

Aaraon Thomas

www.falerpg.com.br

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 63,571
Re: Dice Roller
« Reply #11 on: August 07, 2009, 11:27:50 AM »
Please can you attach your Subs.php file?
And his eyes have all the seeming of a demon's that is dreaming,
And the lamp-light o'er him streaming throws his shadow on the floor

Offline aaraon

  • Semi-Newbie
  • *
  • Posts: 52
  • Gender: Male
    • Fale RPG
Re: Dice Roller
« Reply #12 on: August 07, 2009, 06:58:44 PM »
Here it is! I hope that helps  :D
[]´s

Aaraon Thomas

www.falerpg.com.br

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 63,571
Re: Dice Roller
« Reply #13 on: August 09, 2009, 10:33:05 AM »
Spectacular, I managed to break it entirely with my previous fix.

Reuploaded version - http://custom.simplemachines.org/mods/index.php?action=download;mod=2032;id=110583 - should install cleanly now on 1.1.
And his eyes have all the seeming of a demon's that is dreaming,
And the lamp-light o'er him streaming throws his shadow on the floor

Offline aaraon

  • Semi-Newbie
  • *
  • Posts: 52
  • Gender: Male
    • Fale RPG
Re: Dice Roller
« Reply #14 on: August 09, 2009, 06:28:36 PM »
IT'S ALIVE!!! IT'S ALIVE!! err...  I mean... It's working fine! Thanks!





Sorry for the trouble!  O:)
[]´s

Aaraon Thomas

www.falerpg.com.br

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 63,571
Re: Dice Roller
« Reply #15 on: August 09, 2009, 06:30:02 PM »
No worries, my bad for not writing it nicely the first time :)
And his eyes have all the seeming of a demon's that is dreaming,
And the lamp-light o'er him streaming throws his shadow on the floor

Offline aaraon

  • Semi-Newbie
  • *
  • Posts: 52
  • Gender: Male
    • Fale RPG
Re: Dice Roller
« Reply #16 on: August 09, 2009, 06:51:38 PM »
You can't imagine all problems and my forum is an magnetic for problems.

If you accept sugestions, a way to not edit the roll. My players are not reliable. :-P
[]´s

Aaraon Thomas

www.falerpg.com.br

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 63,571
Re: Dice Roller
« Reply #17 on: August 09, 2009, 06:59:02 PM »
Actually, the first release was stupid because I didn't check something in 1.1, the second I typo'd the install script, but this version works.

Re editing: The simplest solution is to remove the ability of players to edit their own posts.

I did look at doing it with a database, but I simply couldn't find a way that was still fast didn't require weeks of extra coding which I didn't (and still don't) have the time to put in. Maybe a later version though.
And his eyes have all the seeming of a demon's that is dreaming,
And the lamp-light o'er him streaming throws his shadow on the floor

Offline aaraon

  • Semi-Newbie
  • *
  • Posts: 52
  • Gender: Male
    • Fale RPG
Re: Dice Roller
« Reply #18 on: August 09, 2009, 08:41:08 PM »
At this time this dice roller is perfect! I'm all praise!   ;D
The last thing I want is to belittle for all the work that you had!  :o I will continue accompanying your work. Now it is only the congratulations!  ;)
[]´s

Aaraon Thomas

www.falerpg.com.br

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 63,571
Re: Dice Roller
« Reply #19 on: August 09, 2009, 08:46:38 PM »
Good to hear :) Seriously though if you do come up with things you'd like to see I'll see what I can do about adding them here.
And his eyes have all the seeming of a demon's that is dreaming,
And the lamp-light o'er him streaming throws his shadow on the floor