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

Loot Table API

Hello! Long time GM, no time API person. I want to make rollable loot table thingy for Bunkers and Badasses, a Borderlands-inspired tabletop game with lots of loot tables a modular weaponry (and if you use homebrew, modular a lot of other stuff). I don't mind manually rolling, but I have potential GMs intimidated by the rolling of guns and how time-consuming it looks to roll the tables and then construct the weaponry. This is complex, I know, but I was hoping I could get some help with making macros that can auto-roll all the stuff and construct guns and other things (there's a lot). Just having a basic macro I can manually edit myself to add all the gun parts/guff would help a lot, though there's some intricacies such as players having skills that modifying chances of finding certain kinds of guns that would be nice to account for. To get the bare basics across, a gun has a manufacturer with a bonuses based on rarities, 5 rarities, gun types with damage dice that change based on 5 tiers of play, and a chance of one of 6 elemental damage type based on the gun's rarity. Other things are simpler, just a roll on a chart, or if it's some fancy homebrew, one of several manufacturer's with a bonus and a "type" that has an effect (and MAYBE an element). I know that's... a lot, and I really haven't explained all the intricacies. I wasn't sure if it would be a good idea to explain literally everything I'd like to start with. And if it's worth mentioning, I'd be very happy to pay for assistance in getting these tables working. Thanks for the time!
1756510141
Gold
Forum Champion
So that's going to be over my head, and I don't know the game system, but perhaps I can help initially with honing your question and terminology, to get to the heart of what you're looking for. Or, maybe someone else will come along and understand it from the OP. To me I think your question can be refined.  I'm interested to figure out, what is your question exactly? Do you want to write/create a new API Mod script, so you need help with writing API code?  Or did you mean.... you want to use an existing API Mod Script to import rollable tables copied from somewhere else (like a spreadsheet)? If so.. Which Mod, is it one called Loot Table?  Is there a reason you need API at all, why not just create rollable tables and roll them?  Have you created any of the Rollable tables yet? If so, what problem are you running into specifically, where it's not doing what you want? Or.... was your question recruiting for an expert of that Game System or of Roll20 API, and asking if someone else can do this for you (and I see that you offer to pay them)?  What I'd be looking for, in reading your question, is not necessarily more details of the Game System that you want to implement (that can come later), but for starters just what area of Roll20 do you need help with and what kind of help are you looking for? 
1756524633
timmaugh
Forum Champion
API Scripter
I'm with Gold that we need more information about where exactly you want to get to... But I can say that this should not take a whole new script, unless you want the practice and learning aspect of it. If all you are looking for is to have a single action (clicking a button to start randomizing) navigate all the way through the tables, including all contingent or contextual rolls, either Recursive Tables or the MetascriptToolbox can do that. Those are existing scripts.
Thanks for the replies!  So first of all, I'm not entirely sure of the different between rollable tables and API, as nouns and terminology are a struggle for me and it's hard to know where to start making sense of it. That said, I believe a rollable table can't, say, "generate" a result that compiles everything into a "pretty" most. So to try and be clear what I mean, what I'm looking for is either tips on how to start making this program/script that would work on Roll20. I have no idea how to get started, and found roll20's guides a little hard to parse. If they are the best place to start, I will power through, but I was hoping to see if there was an easier path to what I wanted to get. The offer of payment is in case there's an expert that wants to create this wholesale, or teach me the basics, as I wish to respect other people's time and I'm not sure how hard this is. (I realize this opens me to being taken advantage of, but I personally prefer to assume well until proven otherwise). To be most specfiic on the actual thing I want to get, the table/script I desire would take all the following information swiftly and put it into a pretty post the players can ready and easily copy-paste from. So it would; 1. Check tier of play as imputed by the GM or player (this affects later things) 2. Roll a D8 for "manufacturer". This will decide the weapon's damage dice, critical dice and bonus effects such as bonus or reduced damage, bonus critical dice, increased or reduced accuracy, ect. with higher tiers of play altering the stats further. Certain generated weapons have a bonus to "elemental rolls", a later step, and so need to be checked. 3. Roll for the item's rarity (this involves, going off the original game's tables, involve a 1d4 roll then a 1d6 roll against the 1d4 roll, with the d4 deciding the table the D6 rolls on). These results can be (rarity) or (rarity with chance of element). 4. If the result says "chance for element", then roll a 1d100 for the element (based on the rarity that was gotten from the last step). The generated "manufacturer" can add a +10, +15, or a +20 to this result. 4.5 Have a toggle/option to add a +20 to the element roll from a player feat. 5. Have an option for the GM to toggle a roll a d100 for "prefixes", a word for the gun that gives a bonus effect. It's important to be able to turn this on or off. 6. Have the option for the GM to add "Red Text", a silly phrase that has no obvious mechanical benefit but secret does something to the weapon that will not be shown to the players by default (though having the option to display the effect just in case the GM wants to show the players would be nice). 7. Same as 6, but instead "Teal Text". 8. Compile this result into a single post or card that's relatively easy to read and copy-paste from. It will be manually added to a sheet afterwards. As an example, it might look a little like this; You got a (Tier 2) Uncommon Hyperius Shotgun! Manufacturer Bonus; +2 ACC MOD, -2 DMG MOD Gun Bonus; If range 2 or less, +2 damage. Range; 4 Deals 2d8 Fire Damage Per Hit 2-7  8-15 16+ 1 Hits, 0 Crits 2 Hits, 0 Crits 2 Hits, 1 Crits I assume that if something like this then existed, it would be relatively easy to duplicate for other weapon tables that are, thankfully, much simpler and would roll ony 2 or 3 "parts" before putting them together into a result. As timmaugh has say Recursive Tables or MetascriptToolBox exists, that seems to be the case. I will look into these, but would still appreciate any other information!
1756744613

Edited 1756744908
Gold
Forum Champion
I think (in my opinion) your first step is start building out any & all Rollable Tables that you can. You don't really need anything special for getting started with that; just typing, data-entry skills.  In Roll20 > Create Game > Launch Game > go to the Collections tab > scroll down to Rollable Tables > Add new Rollable table. Fill it in. Create another one. Keep going.  You can "roll" the rollable table with a Macro in Roll20. Create your 1st macro to Roll a rollable table. The output could say " You got a (Tier 2)".  You got a [[1t[tiers]]] Edit your macro to support 2 rollable tables. Now the output could say " You got a (Tier 2) Uncommon". You got a [[1t[tiers]]] [[1t[how-common]]] Keep going.  If you run into something that the Rollable Tables and Macros cannot do, then you could ask about creating an API Mod script to do what you want, or whether an existing API Mod script can help at that point. 
1756780026
timmaugh
Forum Champion
API Scripter
Gold has an excellent suggestion as a way to start. Let me see if I can backfill with some disambiguation of the terminology. A "rollable table" is a feature available to all pay tiers of Roll20. It's a table of data that can be randomized to return any result. There are only 3 datapoints associated with any entry: Name Avatar Weight "Name" is text. "Avatar" is an image (if you want to use it). And "weight" is the relative weight of this entry among all other table entries. Roll20 will default all items to be the same weight (1). Therefore, if you wanted to simulate a d8, you would have eight entries in your table, each of weight = 1. Since you set up the probabilities to be the same as if you'd rolled a d8, your rollable table lets you cut to the chase: instead of rolling 1d8, getting a 7, then consulting your rulebook table to see what that represents, you would simply roll from your in-game rollable table and the randomization would return (for instance) the 7th entry, which is the text from your table that you would have been looking up anyway. A "script" is a fuzzier topic since it can refer to a few things. I think classically (and most conservatively) it refers to a "mod script", which is a bit of javascript code that can be added onto a Roll20 game by a GM (provided that the game owner is of Pro subscription level with Roll20). These scripts utilize the Roll20 game API to take action on the game in different ways. For this reason, these scripts are also called "API scripts" or just "the API" (which might technically be an error, but it's just a shorthand reference to the way these scripts use the API, so it works). RecursiveTables and the MetascriptToolbox are scripts in this category. Another category of "script" is a command line intended for the ScriptCards mod script (a script of the former category). ScriptCards is a script that allows programmatic, function-based command lines (that is, the things you can do with a proper coding language like declaring variables, running if/then branches of code, etc.). A command line intended for ScriptCards even starts out: !script ... ...so you can see why people might shorthand this sort of thing to be a "script"...  The last way people use "script" really isn't a script at all... but builds on that previous usage as a way to generally refer to ANY command they build and save for later use. A better term for these commands are "macros" or "abilities" (if they are saved on a character sheet). Anyway, that's why, when you say, "I want to build a script", we have to take a minute to understand if you really want to write javascript code, or if you want to just build and save a command line that will utilize existing scripts. One other thing... as you start to build your tables and enter your data, you may find that you can handle everything in a single pass. Where you need to give the GM an option to include a component of the output or not (like the d100 for prefixes), you can use a roll query. Where you need to actually return the result of a d100 table (like actually returning the value from a table), you create a table and roll against it. You can even put all of that in a roll template and have a nice looking output. On the other hand, you may find that you can't easily handle it all in one go. For instance, there is a step in your process where you have a chance for an element that is "based on the rarity". In this case, you'd be using one table return to drive another. If you get rarity-A, you need to roll from among the elements available to rarity-A. The ideal way to handle this would be inline rolls contained *within* the rarity entry. For instance: Rare Rare [[1t[RareElements]]] Moderately Rare Moderately Rare [[1t[ModeratelyRareElements]]] ...etc... You can't do this natively with Roll20. You can't roll against the Rarity table: [[1t[Rarity]]] ...obtain a result like: Rare [[1t[RareElements]]] ... AND have that new inline roll detected and rolled from the table return. This is where a true mod script (like RecursiveTable or the MetascriptToolbox) can help. Also ScriptCards offers tools to solve this problem, so I should mention that. But short of requiring that recursion through inline rolls contained in table entries, you might be able to get away with standard Roll20 syntax and rollable tables to accomplish what you're looking to do.
1756930818

Edited 1756931096
Thank you both SO much! It helps so much you, Gold, demystified the initial steps for me, that will REALLY help me get started! I think this will give me enough to at least get started. I'm a little bummed it doesn't sound like it'll be easy to transfer this work from game-to-game without copying the whole thing, but better to get started than not.  As gold said, I'll start by just making some roll able tables, see if that accomplishes pretty much everything I wanted anyway. Afterwards, I'll go looking into Scriptcards to see if that can streamline the process. Again, thank you SO much~!
1756931430

Edited 1756931465
Gold
Forum Champion
The Conflicted said: I think this will give me enough to at least get started. I'm a little bummed it doesn't sound like it'll be easy to transfer this work from game-to-game without copying the whole thing, but better to get started than not.  With Roll20 PRO account everything should be transferrable to another Roll20 Game of yours using a Pro-only feature called Transmogrify, transmogrifier. Even if you only get Roll20 Pro for 1 month, do your transfers, and then revert back down to Plus. However it won't be transferrable to Games created by other GM's. For that you could just offer Copy-Paste thru forums. 
1760793027

Edited 1760793180
Dunno if anyone will see this, but here's hoping! I'm working on Roll tables and macros, most of what I wanna do can be accomplished! Thanks again, Gold and timmaugh! It's basically as fast as I need it to be. That said, there's one stumble I've hit. Is there a way to make a roll table be affected by a macro's roll query? So for example, there's a table called "elements", and it has a d100 rolls for it (I'm aware you can add "weight" to roll tables on that note). Is there a way to make the roll query add the inputting number add to the roll on the roll table? Thanks in advance if anyone answers. Bonus question; is there a way to make a macro, if a certain result is given, roll on another table? An if/then statement sort of thing?
1760885664
timmaugh
Forum Champion
API Scripter
As far as... rolling against a rollable table with an offset... not natively. I think Roll20 has this on the stack of deliverables they are working on, but unless I missed it I don't think this has been finalized and/or released, yet. However, with scripts you can do this. Specifically the Metascript Toolbox. If you are willing to go to the "Pro" sub level to get access to scripts, I can demonstrate the process. As far as... recursively rolling a new roll that is in a return from a rollable table... again, not natively. A script like RecursiveTables can do this for you, but I'm not sure if that *also* handles rolling with offset. The MetascriptToolbox can also unpack a return from a rollable table to detect if there is another roll, there, and it can do this as many times as you have table references. So, again, if you're willing to go Pro, we can show some suggestions/examples. That said, there are some tricks (to balance probabilities) that can be fudged with out-of-the-box Roll20 table functionality. These involve multiple tables and/or weighting entries to account for flattening of deep table structure... ...for instance, if TableA has 10 entries, 9 of which are terminal but 1 is a roll against TableB, and... ...if TableB has 5 entries, all of which are terminal, then... ...you could flatten TableA and TableB into a new table where you have the 9 terminal entries of TableA each weighted at 5, and each of the TableB entries weighted as 1. That way, the probability of getting any return from the original TableA is still 1-in-10 (5-in-50), and the probability of getting any entry from the original TableB is still 1-in-10 multiplied by 1-in-5, or 1-in-50.
Sadly the tables I have are too complex for that sort of cheesing to work, but thanks for the advice! I can't go pro at the moment, alas, but your help is still appreciated! Here's hoping Roll20 adds this feature sooner than later.