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 .
×

[Script] 2024 MonsterHitDice and Token-Action-Maker

1789848659

Edited 1790020169
I am not the author of either of these scripts and I have not asked their permission. I have simply made the changes to make them work on 2024 character sheets (and games). If you don't care about the what/why, you can find both fixed scripts below. MonsterHitDice 2024:  here Token-Action-Maker 2024:  here For the original authors and their sources, I will credit them here: MonsterHitDice Token-Action-Maker In a nutshell, the old API scripts read a character by hunting through attribute objects with `findObjs()` / `filterObjs()`. The 2024 (Beacon) sheets don't expose attributes that way, the properties have different names and are fetched one at a time via the async `getSheetItem()` (and need an experimental sandbox). MonsterHitDice - swapped its two attribute reads to `await getSheetItem()` and made the roll function async. Token-Action-Maker - same swap for detecting NPCs and listing rows, plus the 2024 action names for the buttons it generates. If you are the author of either and would like me to open an pull request, or to shout at me to take them down and rethink my life choices, you can do either here or via DM. For everyone else, I hope this is helpful.
1789851580
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hi Lachleo! I do have a version of Token Action Maker that is designed to work with Beacon. I have not released it due to: A) some quirks in how the IDs are delivered. A very small, but significant part of the time, the sheet serves up a totally fictitious UUID for a given sheet action. This appears to be far less common than when I developed it year before last., and more importantly— B) Beacon is sloooooooooooooooow to deliver information, due to the async way it has to grab info. How long does it take your version to build token actions for a PC with a moderate selection of spells (say, under 20)? Because of these two quirks, which are both beyond my control, I have not released Token Action Builder (the successor of Token Action Maker). I will say that I have made it available for Roll20 to use internally to create token actions for 5.5e modules. And I have been wrestling over whether to release Token Action Builder, but with the caveat about the speed. I'd like to test your version, though, before granting my blessing to put it in the repo. Thank you for the courtesy, though of course you are under no restriction to submit it to the repo anyway, hopefully under another name, just so I can continue to maintain the original. I'm going to install your copy and see what's waht. And thank you again for undertaking this.
1789853398

Edited 1789855493
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
OK, I have installed, and I think you have forced my hand. I will release Token Action Builder to the repo with the next merge. You have my admiration for your effort (I had the cooperation of the dev team when I was developing mine, and was able to get them to reveal some needed attributes that had not yet been revealed. But in my tests on the same character, I cam up with: Lachleo TAM: 2 minutes, 30 seconds to process a moderately complex 7th level wizard Keith TAB: 1 minute, 15 seconds to process the same character. That's a PC. A simple NPC like a hobgoblin  processes in something like 2.3s. Here, your script actually performed better, about a second, but there are other considerations. See below. Also, the new Token Action Builder builds what I feel is a more useful spells macro, breaking things out by level, including an info button, and spell slot reporting (although it admittedly takes up more space): Likewise, the TAB version of checks and saves macros presents the checks in a drop down, showing modifiers, and allowing a user to more easily find the needed roll: For this reason, and most importantly, that the actions produced by TAB will exactly match those found in Roll20 modules, I would respectfully ask that if you intend to release your TAM code, you release it by another name and using a different base command (to avoid name collision in the repo for anyone evaluating either).
1789853488
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
And of course, leave your code up here in case anyone prefers it.
keithcurtis said: Beacon is sloooooooooooooooow to deliver information, due to the async way it has to grab info. How long does it take your version to build token actions for a PC with a moderate selection of spells (say, under 20)? You're right on the speed. Sheet getSheetItem calls Time Latency Player (4 attacks, 30 traits, 18 spells) 97 ~12s ~125ms/call NPC (dragon-ish statblock) 24 ~4s ~150ms/call I tried batching unsuccessfully, because its not the bottleneck. The amount of calls to get what you need is genuinely what it takes to do it since there's no batched/bulk api available. Their docs mention using `Promise.all` for fetching multiple vals, but the layer serialises internally so batching was actually slower. For the roll20 team, reading any attribute from a repeating section (attacks, spells, traits) on a 2024 sheet builds that row's entire legacy attribute object and then returns just the single key requested, so a spell's name, level and id are three separate round trips that each rebuild the same object... so enumerating a 20-spell character takes roughly 60 sequential calls. The internal request already carries a list of attribute names but only the first one is ever used, so returning the whole row (or honouring that list) would collapse this to a handful of calls. keithcurtis said: A) some quirks in how the IDs are delivered. A very small, but significant part of the time, the sheet serves up a totally fictitious UUID for a given sheet action.  I got rows by index `($0, $1)` instead of `shortID` to workaround the weird UUIDs.
keithcurtis said: OK, I have installed, and I think you have forced my hand. I will release Token Action Builder to the repo with the next merge.  ... I would respectfully ask that if you intend to release your TAM code, you release it by another name and using a different base command Good to hear, congratulations on the new release. I can just remove this version if you prefer, I really only got these two scripts to work for my GM in our current 2024 campaign and saw a lot of posts along the way from users of either script over the last few years, so I thought it would be useful to share. If you'll release your version this isn't needed!
1789856125
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Yeah, you are preaching to the choir on the abysmal async performance of Beacon. the best metaphor I can think of is: Legacy You want to build something with the character sheet. All the parts are on the table in front of you, in nice labelled organized boxes. You grab the parts you need and put the thing together. Beacon There's a quartermaster. They have all the parts in a backroom. They won't show you the list, but if you ask for it by name, they'll get it. One. Trip. At. A. Time . They'll bring one part out to you and then go get the next one. You would think you could build as the parts come out, but nope. You have to wait until they have brought everything out. The devs are painfully aware of this (scripters have... made their opinions known), but we all need to live with choices that were made over two years ago. Nobody loves this. At least, nobody who wants to script for it. On the front end, for people who just want to use what the sheet gives you, it's pretty amazing. But there's vanishingly small opportunity for community innovation. Too be fair, the devs have gone out of their way to make a lot of the things we would like to do even possible. When the sheet was released, there was practically nothing you could do with it, even basic macro calls. It's better now, but there are some fundamental limitations. And thanks for your thoughtfulness in the way you presented this. It's up to you whether you want to keep the code up. I am planning on releasing TAB as a separate script from TAM. but I may investigate combining them to use the same interface, only calling Beacon routines when required.
1790011335
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
For anyone interested, the code for the newest, Beacon-friendly version of Token Action Maker is available here . Thanks again Lachleo for prompting me to track down and squash the few remaining bugs. As an added bonus, it now runs about 300% faster on Beacon, at least for NPCs.