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

Limits, and potential of the API

1686579358

Edited 1686746884
Hi, I wanted to ask a couple of information about the roll20 API. I state that I don't know anything about them, with the subscription I have I can't even use them, but I understand a minimum of computer science, and a small idea was flashing through my head. I read about one that has an API for "Random HP roller for enemies". My question then was, how much can I edit NPC? For example, can I (hypothetically speaking) create an API that modifies the weapon a monster uses for me? Or write me a brief description of the monster. Maybe taking random elements already written like: "big", "ugly", "with a cut scar", "small", etc... and creating a description like: "This monster is: big, with a scar" Or even modify the stats, perhaps by removing or adding a d4 to a monster's base stats. This way you could create an enemy generator. For example apply it to goblins. The party doesn't meet 3 goblins, but they do meet: a particularly smart spear-wielding goblin, a very ugly saber-wielding goblin and a very large goblin with a lot of health but a very low charisma I repeat, they are just ideas thrown there, but hypothetically would it be possible? What are the boundaries between the interaction between APIs and NPC tabs?
What you describe is possible, but would lead to a large amount of enemies. Each enemy with individual weapons has to be a separate monster.   There is a mod script that assign each enemy token individual hitpoints when dropped on the map. Next to that it is possible to add a description in the token tooltip, which becomes visible when you hover over a token. But this info is only stored in a token, not in the generic goblin character sheet.
1686597622

Edited 1686597930
Gauss
Forum Champion
Martijin , Individual weapons shouldn't require a separate Characters (monsters), just keep adding weapons to the same one. The key is to make a Token Action for individual tokens.  Example:  There are 5 weapons on the Orc character sheet.  Orc 1: has weapon #1 on its token actions, but not weapons 2-5.  Orc 2: has weapon #2 on its token actions, but not weapons 1 and 3-5.  Orc 3: has weapon #3 on its token actions, but not weapons 1-2 and 4-5.  And so on... Lyt , As Martijin stated, HP and AC is easily done on a by-token basis so would not require separate Characters. Where you would get into trouble is when you have different ability scores, saving throws, etc. But you might be able to represent those differences on a token via a macro difference.  Example: Orc "1" has a "1" in a bubble that is not being used for anything else (such as HP or AC). All of the attack, saving throw, etc macros look for the number being held in that bubble and apply a bonus as appropriate to whatever is being rolled.  It is a bit fiddly, but a Mod (API Script) would probably streamline that greatly.  Example:  Lets say Orc 1 is stronger than normal with a +2 Strength.  So for Abilities, Skills, and Saves the Mod adds +1 bonus to Strength based checks.  For attacks the Mod adds +1 bonus to Strength based attacks and damage.  This can be coded into a Macro, but doing it for every token would be an issue. That is where the Mod would come in, it will modify the macros for each of these so that the Token Macros adjust based on the bonuses of the Orc #.  It may be even easier to do all of this on the Mod side rather than an adjustment in each Macro. For that an Mod writer would have to chime in.  Note: this may sound simple in principle but it would probably require significant Mod coding. I am not a coder, I just have a general idea of what can be done and a decade of experience with Roll20. :) If you need help with the macro side I can help with that. 
1686602142
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Gauss said: Martijin , Individual weapons shouldn't require a separate Characters (monsters), just keep adding weapons to the same one. The key is to make a Token Action for individual tokens.  Example:  There are 5 weapons on the Orc character sheet.  Orc 1: has weapon #1 on its token actions, but not weapons 2-5.  Orc 2: has weapon #2 on its token actions, but not weapons 1 and 3-5.  Orc 3: has weapon #3 on its token actions, but not weapons 1-2 and 4-5.  And so on... Token actions are actually defined by the sheet, not tied to a token. They appear whenever a token representing that sheet is selected. However, you can just add a number of attacks to a character, and only use the ones you wish during an encounter. I have given my generic guards a full gamut of basic martial and simple weapons, but I only use the ones specific to that flavor of guard during an encounter.
1686602282
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
To answer the original question, in general, if you can change a token value or sheet value through the interface, you can likely do it with a script. The two most common scripts for this are token-mod for modifying token values, and chatsetattr for modifying character sheet values.
1686608167
GiGs
Pro
Sheet Author
API Scripter
Going back to the OP: this is possible. A Mod can produce anything you can type, and can change any character however you might do it manually. Mods are kind of magical, they can do a lot of things you would never realise you could do. That said, the situation you are describing would need a bit of setup. You might be better either relying on your own description and not using a mod, or creating a generic mod that can randomly draw from a table of descriptions.
1686615710
Gauss
Forum Champion
keithcurtis said: Gauss said: Martijin , Individual weapons shouldn't require a separate Characters (monsters), just keep adding weapons to the same one. The key is to make a Token Action for individual tokens.  Example:  There are 5 weapons on the Orc character sheet.  Orc 1: has weapon #1 on its token actions, but not weapons 2-5.  Orc 2: has weapon #2 on its token actions, but not weapons 1 and 3-5.  Orc 3: has weapon #3 on its token actions, but not weapons 1-2 and 4-5.  And so on... Token actions are actually defined by the sheet, not tied to a token. They appear whenever a token representing that sheet is selected. However, you can just add a number of attacks to a character, and only use the ones you wish during an encounter. I have given my generic guards a full gamut of basic martial and simple weapons, but I only use the ones specific to that flavor of guard during an encounter. Oops, my bad. I don't know what I was thinking. Thats what I get for responding soon after I wake up. :P
Token actions are actually defined by the sheet, not tied to a token. They appear whenever a token representing that sheet is selected. However, you can just add a number of attacks to a character, and only use the ones you wish during an encounter. I have given my generic guards a full gamut of basic martial and simple weapons, but I only use the ones specific to that flavor of guard during an encounter. Drawback from a individual description in tooltips and a generic token bar is that - as GM - you first need to hover over the token - read the individual weapon and then mouse move to select the appropiate weapon in a toolbar with many buttons. This kinda defeats the purpose of token actions.  Recently i experimented with Token Action Maker in my games and - oh boy - the level 10 PCs ended up with three rows of tokens :)  
1686665292
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Martijn S. said: Recently i experimented with Token Action Maker in my games and - oh boy - the level 10 PCs ended up with three rows of tokens :) Were you including things like "Traits"? That can really bloat up a PC's list. For PCs I would suggest using the command !ta pc to avoid including those. Most players don't need a token action button to remind them they have darkvision, or stonecunning. Usually it is the number of weapon and spell attacks that will bloat up a list. And you can always deactivate the ones you don't want buttons for.
Yes, told my players: just found this handy dandy script and just did !ta and ta ta woosh a whole screen of buttons :) :) :)
Otherwise is it possible to actually create a different tab for each enemy? (always following the same rules) Obviously after a while they become too many, so at the end of each session you should delete them all. If it were possible to address them in a single folder (so that when they are created they immediately end up there) it could be a way to not mess up the DM Journal too much. I imagine that this solution is a bit cruder and takes up more space, but at least it should be possible to change the stats and weapons for each individual NPC as well (without having to overfill the token's actions, which is still a valid alternative)
Yes, that's a common practice: duplicate  and adapt monsters.  And then after the game you create a folder, move all disposable NPCs in that folder and then delete the folder with all content. 
1686761299
The Aaron
Roll20 Production Team
API Scripter
A script could create the duplicate characters as Archived, and they wouldn't show up directly in the Journal, then have a command to clear them out later.  From an API perspective, it would be easier to store the variations on the API side, and provide a menu for each monster, like a mini character sheet in chat, with buttons for each of their actions.  You could have a standard command to display that "sheet" for the selected token, and it could be cleaned up in the script when the token is removed.  (Could even store the data for it on the token, so there's no waste.)  It would be a couple of step process (select token, click macro/token action to see "sheet", click option), but pretty efficient.  You could even have it show automatically when that token's turn comes up.  You could have it auto generate the variations when the token is added to the TurnOrder, or pregenerate them if you want to do some fine tuning.