Tabletop Simulator

Tabletop Simulator

46 ratings
Roll-O-Matic - Scripted Dice Roller
   
Award
Favorite
Favorited
Unfavorite
Assets: Scripting
Tags: Misc
File Size
Posted
20.028 KB
6 Mar, 2017 @ 4:58pm
1 Change Note ( view )

Subscribe to download
Roll-O-Matic - Scripted Dice Roller

Description
A scripted dice roller that actually rolls dice. It is an infinite bag with number buttons on it. Click a number and it spawns that many dice in a circle around it, already rolled. It can then announce the roll.

Features?
  • Rolls 1-9 dice at a time.
  • Works with any dice or custom dice.
  • Can automatically remove the dice rolled. (optional)
  • If dice still exist when you roll again, it will then automatically remove the old ones.
  • It can print the roll results and adds them up.
  • It can put roll results in order. (optional)

What can I modify without knowing scripting?
  • What kind of die it rolls (Any default or custom dice)
  • How far from the tool the dice are placed.
  • How high off the table they are spawned.
  • If the dice are removed automatically after each roll completes.
  • If it is automatically removing the dice, how long it waits to do it.
  • If it prints the results of the roll.
  • If it puts the results it is going to print in ascending order.

Known Bug
If you reset the tool so it does not contain a die, and then press a number button, it will print an error and then it won't let you press more number buttons. To correct this issue, hitting the X button will allow you to press a number button again (after you go ahead and add a die!).

This bug is because I cannot currently determine if the bag holds something or not without it throwing an error if it doesn't. But no big deal, it won't break the tool as long as you know how to right it.

Special Thanks
I want to thank forum user Revinor for working out the quaternion foruma to get a nice, random result. I credited him in the function itself (in case anybody copies it over for their own work) but he cracked a problem that stuck me but good.
35 Comments
Harvester 6 Dec, 2022 @ 4:52am 
Is the mesh for this now missing or is just me? And I never backed this up.
Pepper0ni 21 Jan, 2022 @ 9:59am 
Thanks for uploading this mod, I made edits to make it more coin friendly, user friendly to configure and fix that known bug. I credited you both in the code and the mod page. The result is here for anyone curious https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2726859747 .
MoonkeyMod 28 Dec, 2020 @ 10:58am 
On further investigation it would seem that my die script is triggered by onRandomize which is not being called in the roller I beleive. As your rollers designed to work with players choice of dice, would you consider adding something along the lines of die.call(”onRandomize") to the rollers script? This would give your rollers broad compatibility for third party scripted dice, mine included ;)
MoonkeyMod 28 Dec, 2020 @ 7:11am 
Hi mrStump, I have a mod that includes asset bundle die that play sound on 6 and print on 1 & 6, currently I am struggling to get the functions in my die to be called when spawned by the dice roller, do you have any tips i could look in to at all? many thanks.
Undesignated 12 Apr, 2020 @ 12:50pm 
Hey MrStump, huge fan of your tool! Quick question; say I want an audio file to play when a certain die value is rolled, is there any way to do that with the Roll O Matic?
MrStump  [author] 5 Sep, 2018 @ 5:23pm 
That's an odd one. I've never got those kind of results when running my big randomizing tests, so I'm not sure what would cause it
Z Games 4 Sep, 2018 @ 8:19am 
Dear author. I kind of encountered that, for unknown reasons, in some sessions the roller will continue to roll 1 if you are rolling only one singel die, for a very long streak. This happened to me twice. After roll for 5 or 8 I then roll 1 die, then it started to get stuck in rolling 1, which I have to reload to solve. Any possibility that this is happening not out of random?
motte 28 Jun, 2018 @ 4:04am 
Hey, I want to use your nice dice roller for one of my workshops, but it uses special dices that have sides like: [0,1,1,1,1,2] but the dice roller always add the premade numers from 1-6 and give that result. I already changed the rotation value of the dices to the number I need to get calculated and found the nessesary line to change in your LUA script. But I am not so experienced with scripting, can you maybe help me with what I should enter insted of "addResults"???? I tryed "addValue" but that broke it completly :steamfacepalm:
Would be nice to hear from you before I become insane of bad and wrong scripting.
If you need more information you can always ask about.
Kenny 5 Apr, 2018 @ 5:09am 
Oh hey, that's not a problem I wasn't expecting you to do it for me. I was more curious if you had any tips on how to approach doing something like that. Thanks, though!
MrStump  [author] 5 Apr, 2018 @ 5:00am 
Yes, but it gets more complicated quickly. How does it determine which dice are to be counted if there are other dice on the table.You could track "true" and "false" values for each die that gets put into the table, true for moving, then when the roll completes, have it set that entry to false. Then check if any entry is true and, if not, then add the totals of those dice.

But then what if a die rolled goes into a bag or something? Now the roll could be broken. So you need to do checks for if the dice are there. And what if somebody else rolls or moves dice? Now you need to account for locking their roll out so only 1 at a time will work.

All totally possible, but it makes it more complicated than I have time to write/test for the time being, sorry!