Tabletop Simulator

Tabletop Simulator

Roll-O-Matic - Scripted Dice Roller
35 Comments
Harvester Dec 6, 2022 @ 4:52am 
Is the mesh for this now missing or is just me? And I never backed this up.
Pepper0ni Jan 21, 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://steamcommunity.com/sharedfiles/filedetails/?id=2726859747 .
MoonkeyMod Dec 28, 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 Dec 28, 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 Apr 12, 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] Sep 5, 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 Sep 4, 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 Jun 28, 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 Apr 5, 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] Apr 5, 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!
Kenny Apr 5, 2018 @ 4:24am 
MrStump, do you know of a way to have the dice output words instead of just their numbers when rolled?

I.E. Roll 2d6, get a total of 8, output X text
Roll 2d6, get a total of 4, output Y text

I've been thinking that your script here would be perfect for this, but frankly my LUA knowledge is... childish, at best.

In any case, thanks for this because it works fantastically as is.
MrStump  [author] Apr 4, 2018 @ 5:02am 
This isn't a complete script. You'll have to modify it to get exactly what you want. That blank space above return 1 is where you put the code you want to execute when the die comes to rest. print(die.getValue()) for example
MrStump  [author] Apr 4, 2018 @ 5:00am 
So I'm afraid there is no super simple script that I can write you that would also do exactly what you want, because of part 1. But if you understand the principle behind it, you may be able to modify an existing script.

Here is a link to a basic, general script I wrote for the prupose. Hopefully you can modify it to get what you want. https://pastebin.com/z5DULz81 . It is a global script.
MrStump  [author] Apr 4, 2018 @ 4:58am 
Part 2, you need to understand coroutines. They are simple enough. It is basically like a function, but you can pause it mid-run. So when you roll dice, you set a global variable to indicate a roll is happening and then use "while die.resting==false do coroutine.yield(0) end" to wait for it to finish its roll. If you're using multiple dice, you then need to check if other dice are still rolling (by checking that global variable). Once you understand it, it is easy, but learning them is, of course, a small learning curve.
MrStump  [author] Apr 4, 2018 @ 4:58am 
There's 2 parts to that which have a trick involved.

Part 1, you need to know which dice to count. There's tons of ways to do this. Does it count all dice on the table? Does it count dice rolled in the last 5 seconds only? Does it only work in an area? Does it only use dice spawned for the action (like with this tool). Depending how you approach it you get very different levels of complexity.
Galackharg Apr 3, 2018 @ 3:07pm 
Hey MrStump, I'm wondering if you can help me with a simple script. All I want is a scripted die that uses the broadcast all to announce it's roll.

This is what I tried but it is not working. Any advice?

function endRoll(result,numRolls)

broadcastToAll(self.getValue(), {255,255,255})
end
Safir Feb 5, 2018 @ 5:33pm 
Thank you for doing that. If you wanna' go deeper, you should try letting it roll only 1 die, see how that looks. To be honest, I'll probably end up borrowing parts from a couple mods and just making my own, but this mod has charisma, ease of use and simplicity, it's just that I can't shake the feeling of inaccuracies. Confirmation bias, sure, it could explain what we saw.
MrStump  [author] Feb 5, 2018 @ 3:59pm 
That is just the way the dice rolls sometimes. I am fairly confident it is as random as you can hope for. I set it to roll 40 dice over and over, and count the number of times each face came up. I then went to work. This is what I had when I came home. https://i.imgur.com/dnaI2oi.jpg

Yep, pretty random.
Safir Feb 5, 2018 @ 6:15am 
I appreciate you looking into this, but it was ridiculous to the degree that we would just call the rerolls whenever it was a 1 on the one die we rerolled. Played Eldritch Horror and one of the characters had the ability to reroll any 1 result. Maybe the random coordinates generated for the dice posistion and rotation don't vary enough, taken from some function that only gives slight variables when rolled close together in time.
MrStump  [author] Feb 5, 2018 @ 4:53am 
For example, I played a game of Catan IRL where we rolled no 8s all game, one of the highest odd rolls. It doesn't mean our dice were bad or we weren't rolling, it was just a matter of sample size and chance
MrStump  [author] Feb 5, 2018 @ 4:50am 
I ran a test on this before and had it do about ten thousand rolls, and the results were evenly distributed. Most likely, your sample size was just too small along with our natual confirmation bias we have. I'll double check and set up a test for it to make sure nothing has changed though.
Safir Feb 4, 2018 @ 8:33pm 
So, I've played a couple games with this now, and I really like it. Problem is that the dice rolls generated aren't really random. On occasion, most noticeably when rolling one die and re-rolling it after the result has been shown to be a 1 or a 6, it frequently continuously rolls the same number. I haven't edited or changed anything besides it's scale on the board. Any ideas what can be done to prevent this? How can I get my rolls to be random?
Nanovirus27 Jan 18, 2018 @ 1:52am 
Hello Mr.Stump first I must say the amount of things you have put out for Tabletop has helped me out so much and I couldn't thank you enough. I am currently seeking some help from you Me and my friends have designed our own original game and we are using several mods from you. The game is almost perfect I just need your help in getting some scripts to work in a way that helps us. If you can help me out I would appreciate it very much!! And than you for the Mods!!
Dinoworld112 Mar 12, 2017 @ 5:39pm 
Very good
Tragic Mar 11, 2017 @ 3:28pm 
Awesome!
MrStump  [author] Mar 11, 2017 @ 6:51am 
Indeed I did. If you saved one to your chest, you'll need to save over it from the workshop (chest saves don't auto-update).

So far, it was only the randomization system that I ported over. I was guaging interest for porting over the ordering/printing system this tool uses to replace the other system.
Unreal Ed Mar 11, 2017 @ 6:29am 
Did you update the Holy Roller with that rotation script? That mod is still useful
MrStump  [author] Mar 10, 2017 @ 8:34am 
Glad to hear its getting some use =)

When I first made something like this (Holy Roller) I got caught offguard by the randomness of a "sphere" of rotation. Fortunatly, someone posted a good solution on the forums, so I was sure to test it out thuroughly this time around haha
Muskrat Steve Mar 9, 2017 @ 9:22pm 
I figured someone with your mod quality would have run testing to ensure proper rng. I was probably looking at too small of a sample size.

Ive played 1 game with them so far and they worked flawlessly and players commented on them positively. They look really slick and reduce clutter well.
MrStump  [author] Mar 9, 2017 @ 8:54pm 
I've done some extensive testing to be sure. I did it by setting the tool to re-roll itself, and count up how many of each side comes up. Then I let it run for a while until I get a healthy sample size of rolls. Here is a link to the modified script. http://pastebin.com/8A5ZgYY8 The rotation setting is the same as the workshop version.

Each time you run it, a number or two may get ahead or behind, but it isn't always the same numbers doing the leading/tailing. I believe it is at least as random as manually rolling a die. Here's a set of results I just got while running a test: https://www.screencast.com/t/6sDftro5c
Muskrat Steve Mar 9, 2017 @ 6:46pm 
Im not sure how random this is. At least with a D6. I feel like the side that is put in face up shows up more than any others and the side that is face down shows up very little.
MrStump  [author] Mar 7, 2017 @ 6:16pm 
It is possible, just not with one infinite bag. But with trickery you could.
Unreal Ed Mar 7, 2017 @ 4:36pm 
Great mod ! Love the look and layout.

Would it be hard to make a script on a bag, has buttons to spawn dice that's at a certain index of the bag? Like a bag with 2 sets of buttons to spawn x copies of the first and second dice in the bag. I'm not asking you to make it, just curious
MrStump  [author] Mar 7, 2017 @ 5:46am 
I gave assert() and pcall() a try, and came up empty handed in both cases. I couldn't get them to predict the error without enacting it. It may be possible, but if so I was unable to figure it out.
Supposer Mar 7, 2017 @ 1:44am 
Looks like an interesting little gadget! Could you try-catch for the error, perhaps?