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

[Script] Randomizer

I put together this script to have a (hopefully) simple and flexible way to generate complex things from rollable tables. I'm using it for weather, random npcs and loot in a campaign I'm putting together, but it should be flexible enough to generate any sort of random entity. It essentially lets you make rolls against sets of rollable tables based on their names and presents the collected results in chat. It can also trigger additional table rolls from a result. There's an example of that in the last screen shot below. More details on how it works are in a comment at the top of the script. Commands: !randomizer &lt;table-segement1&gt; &lt;table-segment2&gt; n... -- Rolls on the rollable tables whose name's include the provided table segments and reports the results to chat. Switches: --b -- Broadcasts the results to all players. By default whispers the person who invoked the command. Examples: Source:&nbsp; <a href="https://gist.github.com/mattkauffman23/cf179c9fe71" rel="nofollow">https://gist.github.com/mattkauffman23/cf179c9fe71</a>... Please let me know if you guys have any ideas or suggestions to improve things or if you try to use it and hit any issues.&nbsp;
1448996122

Edited 1448996326
I like this, but do you think it is possible to add some sort of option to exclude the results of certain tables being displayed in the final template? For example, your Loot Hoard macro could be configured to exclude the "1x gold b... 2x items a." from the output. The results of these tables are unnecessary information and would be nice to be able to hide. This is especially true when they get nested 2 or 3 tables deep. Overall, very good work! EDIT: Image for clarification.
Thanks! Good idea on hiding some results. I added some code that will look in table's for an item named "hide" or "hidden" and if its found the results from that table won't be displayed. Think that handles what you're describing. I updated the gist linked above. Let me know if you have any other ideas to polish it up or features that would be helpful.
1449154265

Edited 1449155983
Matt K. said: Thanks! Good idea on hiding some results. I added some code that will look in table's for an item named "hide" or "hidden" and if its found the results from that table won't be displayed. Think that handles what you're describing. I updated the gist linked above. Let me know if you have any other ideas to polish it up or features that would be helpful. This is perfect! I'm already using your script for a number of amazing things. I've made a "GM Menu" of sorts for my 5e game, where a single macro calls a bunch of API buttons tied to your randomizer, each pointed to their own rollable table hierarchy. Everything including loot tables, random traps, puzzles, dungeon rooms, NPCs, etc.&nbsp; I'm combining this with The Aaron's&nbsp; Table Exporter to import tables at high speed. I've made an Excel spreadsheet that allows any table to be pasted into a list, which then generates the api commands to be copied back into roll20. I can basically create a Roll20 rollable table with hundreds of items in a matter of seconds. API rocks! EDIT: Some of the effects for my items have the word "hidden" in the effect, which is causing them not to roll. perhaps make the keyword some combination that wouldn't appear in normal chat? Or should I just try to rewrite my tables?
Nice! Glad you found so many uses for it already. Curious how you're using it for puzzles. Can you post a screen shot or something? It was kinda dumb on my part to not realize that hide or hidden would be common enough words to cause an issue. I updated it to use the phrase "hide me" and only trigger the hiding behavior if the table item name is an exact match. So if "hide me" is part of a sentence or something it will still be displayed. I also made the keyword configurable in the script just in case. The updates are in the gist linked above. Let me know if you run into any more problems or have any other ideas. Thanks for kicking the tires!
1449172519
The Aaron
Pro
API Scripter
You might consider something like %%HIDDEN%% in the name.
I was trying to keep setup from being too intimidating for non-technical folks, so I didn't want to introduce any more syntax than I had to. That said I've noticed your name on a lot of scripts and you seem to be the go to guy in the forums, so do you think that's a worthwhile effort? Do you have a sense for how many non-technical type folks are using the API? Also is that a convention that's been established in other API scripts or in some part of roll20 itself?
1449176431
The Aaron
Pro
API Scripter
My sense is that most people using the API are at a minimum passably technical. &nbsp;Adding a special flag word doesn't seem to be beyond any of the users I've dealt with. &nbsp;I've used %% as a delimiter for things in the past (TokenNameNumber uses %%NUMBERED%% as the marker to be replaced with a number when a token is dragged into the VTT). &nbsp;Something like that doesn't come up in normal naming conventions but still tells people what it does. &nbsp; If *I* were writing this, I'd probably set it up so you can add tables into the list of tables being considered, probably by listing out the tables with add/remove buttons next to them. &nbsp;Then a user could do something like !randomizer --adjust-tables and quickly add/remove the ones they wanted to participate. &nbsp;I haven't given it much thought, but I tend to prefer configuration over arbitrary convention. &nbsp;In the case of a table, adding something to the name presents a problem if you want to type it: [[ 1t[Some-Table-%%HIDDEN%%] ]] And a further problem if you decide you want to remove it from that system, as now you have to rename it in all of your macros where you typed it. &nbsp; Still, I've not tried your script out yet (been meaning to!) so my above thoughts are based largely on my perception of what it does. =D
Thanks for the insights. Definitely appreciate it. For now I'm going to update the default to %%HIDDEN%% in the script and consider your suggestions on refactoring the interface to be more command line oriented. I agree with you on configuration over convention in an environment like this where there are so many contributors writing scripts to solve so many diverse problems. The command line approach also unlocks a lot of flexibility for people savvy enough to string the commands together. On the other hand its a bit more work to configure things with commands if you're doing it manually and I kind of like how the table relationships are obvious just by glancing at the list of tables in the main ui (though it would be nice if that list had an alpha sort on it). So I'm going to think on it a bit. If you get a chance to play around with it, let me know if you have anymore ideas.&nbsp;
1449187123
The Aaron
Pro
API Scripter
Will do. &nbsp;You could create a macro for each gm user to start the menu of commands. &nbsp;You'd have to do it when they trigger the chat (offline players are always playerIsGM() == false ).
1449222305
Ziechael
Forum Champion
Sheet Author
API Scripter
The Aaron said: My sense is that most people using the API are at a minimum passably technical. &nbsp;Adding a special flag word doesn't seem to be beyond any of the users I've dealt with... Well most of them anyway ;) On-topic, nifty little script Matt, I'm in the process of mapping out a bunch of tables that will benefit from this thanks.
1449264958

Edited 1449265224
I've made a video demonstrating the functionality of my GM Menu macro. Here is the link. Thanks to The Aaron, Kryx, Matt K, and Stephen S. for their API scripts! This level of functionality wouldn't be possible without their work.
Trigshot that's pretty darn impressive. Great job! Glad my script was able to help you build it.
Good script that will save me some pain!
Matt K. said: Trigshot that's pretty darn impressive. Great job! Glad my script was able to help you build it. Thanks!&nbsp; I used&nbsp; The Aaron's Table Exporter and Importer to import several of the tables used in the GM Menu quickly.&nbsp; I even&nbsp; drew up a Microsoft Excel spreadsheet that can convert a copy and pasted list into API import code for the script automatically. Just paste or write info under the Item Name column, name the table in cell A1, and then go to the Export sheet to copy and paste the code into Roll20.
1449495893

Edited 1449505730
The combination of Exporter and Importer with the randomizer is really amazing. Even inside of a vertical-selection-capable editor like notepad++ it is possible to very quickly generate the import commands for many tables. I will really have to utilize this for random NPC and quirks and to generally flavour up the boring random stuff I currently tend to use the same 10 things again. Simplicity can be so beautiful!
This is great! Thanks for sharing.
1450106343

Edited 1450116038
The more I work with it the mightier it becomes. Although I have found a few things I would really hope you could further improve: 1) Depth first instead of broad first expansion such that firstname,secondname,city shows up in this order after expansion and not in the order city,secondname,firstname in case firstname and secondname are tables. This would improve usability a lot and shouldn't be that difficult to change 2) Provide an alias for a table which is printed instead of the table name. The table names are often quite long and difficult to show structure and propertys and therefore an alias would help a lot. 3) Firstlevel support of multiple rolls. I would love it if !randomizer table*2 would work and I would not have to create a table everytime I need multiple rolls as well as multiple tables on the first level! 4) Reroll Function. Make the name of a cell (left column) to reroll that entry and output the block again with that row rerolled. This allows to quickly generate better fitting attributes, especially in cases where one works with HUGE tables (like me) and you can't make all tables fit perfectly to a person, such that a rich person suddenly by random chance lives in a hut. A simple reroll would be so cool! 5) Option to hide the rollnumber (right column "(x)" ). Cleaner is better. 6) Broadcast Function after roll. I want sometimes to generate a few rolls until I find a cool or senseful combination and broadcast THAT to the players. Really. I appreciate your work sooo much already and with all of this features this might become my most used script!
Hey Wandler glad its working so well for you. I'll take a look at adding your suggestions in over the next couple days. Can't promise everything, but I should be able to get a lot of what you're describing included without too much difficulty.
1450132405

Edited 1450138172
Cool! And one thing: Would it be possible to let players run the command? Maybe could aaron help with that otherwise? I have added so much cool stuff with it, but I want my players to explore the fluff-database :) Here is what I was able to build with your tool, the importer and the help of&nbsp; Trigshot (really... you opened my eyes!)
1450146073
The Aaron
Pro
API Scripter
You can comment out the following (around line 116): &nbsp; &nbsp; // Check permissions &nbsp; &nbsp; if (!playerIsGM(playerId) && &nbsp; &nbsp; &nbsp; &nbsp; _.any(tables, function(table) { return !table.showplayers; })) { &nbsp; &nbsp; &nbsp; return '!randomizer: You don\'t have permissions to make that roll.'; } But a setting might be nicer.
I still get the error: Error: You do not have permission to execute command !randomizer
1450405416

Edited 1450406738
I am getting the following error: /home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:1 orts, require, module, __filename, __dirname) { function g(a){throw a;}var j=v ^ ReferenceError: Shell is not defined at Sandbox. (evalmachine.:1611:5) at eval ( I have disabled everything else, it still keeps happening. Edit: Nvm, I forgot to install command shell. Silly me.
Wandler said: I still get the error: Error: You do not have permission to execute command !randomizer Same here :(
1450805757

Edited 1450822516
@wandler use the command&nbsp; !shell-permission add|remove randomizer &nbsp;"Player Name" Example: !shell-permission add randomizer &nbsp;"The Rick" Be sure to use the quotes if the name has a space, like "Dustin C"&nbsp; In chat it will return an error message but the player will have access to the script :)
I'm having issues on getting the %%HIDDEN% tag to work, ive tried it in the table name and the table item name, both both just add it to the result, anyone able to explain exactly how to use it?
Dustin C. said: I'm having issues on getting the %%HIDDEN% tag to work, ive tried it in the table name and the table item name, both both just add it to the result, anyone able to explain exactly how to use it? Any resolution, Dustin? Did you by chance enter %%HIDDEN% like above, instead of %%HIDDEN%% (with two symbols following the word)? &nbsp;
1457733726

Edited 1457734883
Hi guys, My questions are all over the place this day. Anyways here goes. So inspired by Trigshot I am trying to make my own GM menu (especially with the DMG tables) The DMG Tables roll a lot 1d4 times another table. Is that something that can work with this? I noticed the 2 times and 3 times, but can it work on a 6 possibilities. Also I can't figure the hidden part out. EDIT: Hidden part is fixed
Hi there, sorry if this issue has been resolved and im not seeing it but i am getting an error /home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:1 orts, require, module, __filename, __dirname) { function g(a){throw a;}var j=v ^ ReferenceError: Shell is not defined at Sandbox.&lt;anonymous&gt; (evalmachine.&lt;anonymous&gt;:51:5) at eval ( not sure what to do here any suggestions. oh yeah no other api scripts are on at all.
1458306899
The Aaron
Roll20 Production Team
API Scripter
This looks like a general API issue not necessarily tied to this script. &nbsp;Can you answer a few quick questions: If you save script, does the issue occur again? &nbsp; Does the issue happen when you issue commands or when the API starts up? Are you on the production servers or the Dev server?
The Aaron said: This looks like a general API issue not necessarily tied to this script. &nbsp;Can you answer a few quick questions: If you save script, does the issue occur again? &nbsp; Does the issue happen when you issue commands or when the API starts up? Are you on the production servers or the Dev server? Yes when I save this script again i get same error went and changed on('ready', function to on("ready", function then i got: /home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:1 orts, require, module, __filename, __dirname) { function g(a){throw a;}var j=v ^ ReferenceError: Shell is not defined at Sandbox.&lt;anonymous&gt; (evalmachine.&lt;anonymous&gt;:2199:5) at eval ( i have yet to issue commands i just got to api script or if I'm there already i hit save script i get same error I believe I'm on a regular server
I was trying to follow Trigger863 GM menu demo, and used steps in A GM Menu but I will re do some info to see if it was just user error Think I found it. had to delete D&D 5e Shaped NPC & Spell Importer
Nope still randomizer, i disabled all other scripts and tried just running this one and it errors on me
1458562571
The Aaron
Roll20 Production Team
API Scripter
Ah! Requires the following other scripts to be installed: - Shell (<a href="https://wiki.roll20.net/Script:Command_Shell" rel="nofollow">https://wiki.roll20.net/Script:Command_Shell</a>) I bet if you go grab that script it will start working. &nbsp;Sorry for the confusion. &nbsp;=D
Wewt it works now thanks Aaron
is there a way to randomly roll a macro if i try "!randomizer test" &nbsp;with&nbsp;[[#Condition-Blinded]] as the only thing is the table the api crashes. this is the macro Condition-Blinded&nbsp;"&{template:5eDefault} {{title=Blinded}} {{save=1}} {{subheader=@{selected|token_name}}} {{subheaderright=Condition}} {{subheader2=PHB, pg. 290.}}{{freetext= You can't see You automatically fail any ability check which requires sight. You have disadvantage on attack rolls. Attack rolls against you have advantage.}}" am i missing sum thing or can this not be done?
1461290160
Silvyre
Forum Champion
Mason C. said: is there a way to randomly roll a macro if i try "!randomizer test" &nbsp;with&nbsp;[[#Condition-Blinded]] as the only thing is the table the api crashes. Unfortunately, no; see The Aaron's reply to your other post .
1461296311

Edited 1461301644
i got it working [Blinded](!.&.#.1.3.;.#Condition-Blinded) works by havving a button as the result that you can click removing the . from !.&.#.1.3.;.#
1462190441

Edited 1462190628
Miranda
Sheet Author
Hey! I can't seem to figure out how to get it to combine the tables together. I don't know what I'm missing, but I am having quite the trouble with it. Edit: Silly me, I figured it out! It was right in front of my face. Great, great great script btw.
In regards to the %%HIDDEN%% tag working... It took me 15m or so before I figured it out (needed more cofffeeeeee!), but in hopes of saving someone else some time, here's a crystal clear image showing you how to enable Hidden. You simply add a table entry with that name to the table.