Show random option set text on button press

Hello, I’ve created an option set that contains a list of flavor text that I’d like to be able to show on a button press. I would like to pull a random option each time I press my “attack” button.

The problem is, it seems like bubble will only allow you to randomly pull once per page load, and then keeps using that same option continuously after that. Is there a way that I can “reroll” the random pull each attack button press?

Yeah that’s probably true. Was thinking about adding some list randomization options to Polyhedra.

1 Like

Although, @snarec, note that :sorted is only applied when you call that method. So note that referencing some list :sorted by random will not give a random result if you’ve stored that in a state. You need to get “your list” and :sort it by random each time you need a new random value.

1 Like

Aside: it’s not my fault that Bubble is unclear on this point.

1 Like

Haha, you’re looking to be mvp of my app! I threw a bit of $ karma your way as thanks for what you’ve already done. I’m stupidly far out from actually launching this thing, but when I do I’m sure I’ll be able to spread more karma around :slight_smile:


I got a basic dice roll parser working (format ndsides +/- ndsides … +/- modifier). Perhaps I should release that.

1 Like

While I’ve got you, is there a way to set up polyhedra to be able to add a dice roll value to an option set’s attribute?

Example: I have an option set called weapons. One of the options in the set is a “Glowing Sword of Keith”. I’d like to be able to set an attribute “damage” for this weapon to 2d3 + 4

or something like that, but option set’s don’t seem to like custom values like that out of the box.

You can’t dynamically change option sets. What you want to do is make (whatever-it-is) that a Thing (custom datatype).

1 Like

Could I save it as a text attribute in the option set (such as 1d5 + 3d3), and then use “parse and roll” on it to calculate damage in a workflow? Or would it be worth me redoing things to put all my weapons in a data set regardless?

That’s exactly what it’s for. Let’s say you have a field on Monster that’s “Damage”. You just write that as a text as (for example) 2d12 + 2. And then you just pass Monster’s Damage to the Parse and Roll. Then, you will get the “Dice Rolled” event and the values in Polyhedra’s dice-related outputs have the result(s) in them.

The rules for the parser are that you have to have number d (or D) sides followed by a plus or minus sign and additional dice or mods. So, legal value examples would be:

1d6 + 1d6

(the same as)


Or, completely bonkers:

2d4 + 2d6 + 2d10 - 2d4 - 3

(roll 2d4, add 2d6, add 2d10, roll 2d4 and subtract that, then subtract 3)

1 Like

The way it works is like this:

  1. remove all whitespace and non-numeric, non-plus-or-minus characters from the string. Convert all characters to lowercase (meaning that “D” is the same thing as “d”)
  2. split the string at any + or - boundary
  3. do what the splits suggest
  4. if there’s no “number” before the xd, assume 1 for x

This can still leave you with some bogus values. For example:


Will yield the same result as “1d6”.

But d6d4 will yield the same result as “d6” (e.g., 1d6).

If you wanted to do “d6 d4”, you should annotate it as:

1d6 + 1d4

This shouldn’t surprise anyone, but I’m just describing how this works.

1 Like

Hi there, @snarec… I know Keith’s got you covered here and you guys went in a different direction with this thread, but for what it’s worth, if you set a custom state (which has a state type of Miss Flavor Text) to a random item from the option set when the attack button is clicked (set the state to the expression you are showing in your screenshot without Display at the end) and then show the custom state’s Display in the text element, you will get the desired result of a random item being pulled from the option set every time the attack button is clicked.



That’s partly what I was trying to explain. Thanks, @mikeloc ! :+1:


Sorry, @keith… I got lost pretty early there, but that’s on me because, well, I’m just not the sharpest spoon in the shed.

By the way, man, go to bed!


I will not sleep until all of the monsters have been slain, @mikeloc. It’s part of my oath.


If by monsters, you mean forum ridiculousness, then sleep will never come. I’m on watch now, oh great half-elf-necromancer/thief/mage… so, rest well.


I’m pacific time. And at my vacation home in Palm Springs. So, still kind of early.


I know where you are (well, I didn’t specifically know Palm Springs because that would be weird), and I love that you consider 1:07 AM to be still kind of early.


It’s not “late” on a Friday. Especially on a holiday weekend…


Can you expound on this part? I’m fairly certain I have the rest of this set up as you say, but when I try and add dynamic data to my text element showing the custom state’s display isn’t an option.