Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Sound and image from a rolling table

Hello, on the entries of a rollable table I wrote the following lines, which allow you to have both a result and an image which is displayed in the chat. Example of the first line: SPIDER-PIG! [x](<a href="https://i.imgur.com/5HFIXAU.png" rel="nofollow">https://i.imgur.com/5HFIXAU.png</a>) Now what I would like is for, in addition to the image, a sound from my library to start playing. Can anyone help me?
1697217811

Edited 1697217825
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hi BRISEBARBE! You might be able to do it with Customizable Roll Listener if you made the table roll inside of a roll template. (CRL only reacts to text in Roll Templates, IIRC). Have it listen for "SPIDER-PIG" inside of whatever Roll Template you choose, and use something like Simple Sound to play the sound.
1697222263
timmaugh
Forum Champion
API Scripter
You can also use the MetaScriptToolbox to do that. Muler can roll against your table with a die roll, and then it can re-use that die-roll against another table (or a Muler mule-ability, which is like a table, in structure) in order to pull an associated piece of information. For instance, if the die result of "3" represented the Spider-Pig, above, in the secondary table the number "3" would be associated with the correct sound for the Spider-Pig. Then it's just a matter of feeding the returned text (the audio file name) to a script like SimpleSound to play... in other words, you'd embed the Muler-get statement in the SimpleSound command line.
Thank you both for your quick responses! I installed Simple Sound specifically for this. Unfortunately, I am far from being an expert (even a bit of a newbie to be honest) and your explanation is still unclear to me. Sorry to ask, but could you explain this to me more simply with a written example or with screenshots?
1697305424
timmaugh
Forum Champion
API Scripter
OK, here's an example. I'll have to make many assumptions about your table setup, but hopefully it will be clear enough (and you will understand well enough) that you can modify it for your particular setup. Let's assume you've named your table of entries "Creatures"... and that each entry is formatted like: SPIDER-PIG! [x](<a href="https://i.imgur.com/5HFIXAU.png" rel="nofollow">https://i.imgur.com/5HFIXAU.png</a>) Finally, it will matter the total "weight" of every entry, so for now I'll assume they are all equally possible (a weight of 1), and that there are 10 items in the table (so a 1 in 10 chance of getting any of them). Next, we'll set up a table of entries for the sound effects for each creature you have in the Creatures table. The entries for this table are 1) in the same order as the Creatures table (so if the Spider-Pig entry is #7, it will be #7 in the sounds table); and 2) the weighting is the same for each entry. Let's call this table CreatureSounds, for now. Enter the names of the tracks for each corresponding creature into the rollable table items (so the #7 entry -- for Spider-Pig -- might say "SpiderPigTheme"). With that setup, and with the MetaScriptToolbox and SimpleSounds scripts installed, you can roll a 1d10 against the table, and use the same result to pull the sound file from the other table. It would look like this: !{{(^) &nbsp; get.Table.Creatures.[[1d10]].value/get &nbsp; !splay get.Table.CreatureSounds.$[[0]].value/get }} That would retrieve the name + image from one table, and the sound from another using the same roll. Bonus: Templated Output I like to have the data points separate (name vs image vs sound). So, if you had the artwork in your library and wanted to attach it to listing in the Creatures table (so Spider-Pig would also have the image that you are currently referencing by URL), you could get it to display in chat by using this Muler formation: get.Table.Creatures.7?image/get To test that in chat (in a way that makes sure you see something), run this command: !get.Table.Creatures.7?image/get {&amp;simple} ...where you have at least 7 items in that table (change the number, otherwise). With that kind of differentiation, you could include a template entry for the name of the Creature/Character you are showing, and another for the image: !{{(^) &nbsp; {^&amp;template:default}{{name=Proof of Concept(}) [[1d10]] ({)Roll=$[[0]](}) ({)Creature Name=get.Table.Creatures.$[[0]].value/get(}) ({)Image=get.Table.Creatures.$[[0]].value?image/get)(}) &nbsp; !splay get.Table.CreatureSounds.$[[0]].value/get }} If you didn't want to have to upload this art to your library (and have it count against your storage quota, you can still reference it separately so that you can generate templated output... you just have to separate the current Creatures entry into 2 separate entries. Let's change the text of the Creatures table item entries to be the name of the thing (i.e., "Spider-Pig") and then put the image url component (i.e., "[x]( <a href="https://i.imgur.com/5HFIXAU.png" rel="nofollow">https://i.imgur.com/5HFIXAU.png</a>) " ) in another table. We'll name the second table CreatureImages. Again, each item should match up (in the same order, with the same weight) so that we know if we are looking at item 3 in one table, we'll get the matching information if we look at item 3 in the other tables. With this setup, you could generate a very similar output to the above (where the image is in a different part of the template) by using this command: !{{(^) &nbsp; {^&amp;template:default}{{name=Proof of Concept(}) [[1d10]] ({)Roll=$[[0]](}) ({)Creature Name=get.Table.Creatures.$[[0]].value/get(}) ({)Image=[x](get.Table.CreatureImages.$[[0]].value/get)(}) &nbsp; !splay get.Table.CreatureSounds.$[[0]].value/get }} And that would save you having to have the art in your library, counting against your quota. Let me know if you have any questions.
Thanks a lot for your help! Unfortunately, I have not yet had time to test your proposal. As soon as I have the chance I will come back to you to let you know if it works. Thanks again :)