Tabletop Simulator

Tabletop Simulator

Not enough ratings
Color Changing Die for Vampire
   
Award
Favorite
Favorited
Unfavorite
Assets: Scripting
File Size
Posted
6.322 KB
6 Sep, 2016 @ 5:20pm
1 Change Note ( view )

Subscribe to download
Color Changing Die for Vampire

Description
Turns black on a 1, red on 2-7, and green on 8-10.
11 Comments
IchigoLeFevre 15 Mar, 2021 @ 2:35pm 
how do you get it to change color? i loaded it in and rolled it a few times and it didnt change any color. rolled 1, and 9 and 5 and 3 and no color change. exited, loaded a new singleplayer game with the mod and it still didnt change colors..
Nath 9 Aug, 2017 @ 4:58am 
You can react to randomization, which covers the R key and the roll option in the context menu, but I don't think there's a way to react to flipping and rotating. It bugs me even though there's no real need to worry about it.
MrStump  [author] 26 Jan, 2017 @ 3:35pm 
Alex, you are correct. There is not currently a simple way to detect the "flip" key press.

One could put an update that constantly checks if the die is resting and then, if it goes from not resting to resting, do the color detection. This would cover all instances of bumping and such.
Alexander Knows 26 Jan, 2017 @ 1:18pm 
Hello Mr. Stump,
Thanks for this scripting, it's going to be helpful for me.

I did notice one small issue. This appears to only work if you pickup the die and toss it. It doesn't work if you use the "R" key to roll or use the right-click menu to roll. Is it possible to get this to work from the other methods of rolling?

Thanks again. I'm studying all your projects as I learn how to code in TTS.
-David
darleth 15 Sep, 2016 @ 9:19am 
thanks
MrStump  [author] 13 Sep, 2016 @ 5:52pm 
Super simple version, if you look in the code, you'll see it starts the coroutine when the object is dropped. Then look at the while loop. When that while loop becomes true, then the rest of the code runs just after the while loop. In this case, getValue() to get the face value of the die. I hope that's a better explanation
darleth 13 Sep, 2016 @ 11:52am 
no...I cant image how you did it...thanks.
MrStump  [author] 9 Sep, 2016 @ 6:59pm 
Haha was that sarcasm?
darleth 8 Sep, 2016 @ 11:49pm 
Thanks a lot...
MrStump  [author] 7 Sep, 2016 @ 4:01am 
Yes. First, it watches for the die to be dropped. This starts a coroutine. The while loop keeps looping the coroutine, basically waiting for the statement in the while loop to stop being true. It does this by yielding 0, which is telling the coroutine to keep looping. In this case, the object resting is what we are waiting for.

Once it IS resting, you can get value off a die using getValue() (the same number that pops up in a tooltop when you mouse over a rolled die). Then you set the die's color tint depending on what face it is. Finally, you yield 1 on the couroutine, signaling that it is now finished.