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

[API] List and Toggle Equipment (5e OGL)

It looks like there are several API that do very fancy things with Inventory items, and that some have been around a long time (old?). I am looking for an API that will help the GM & Players quickly see what inventory items are set to "Equipped," and to toggle them on/off from chat. Is there an API that will: Output to Chat a character's Inventory, showing the item name and its "Equipped" status, (e.g. yes or no) Allow the user to toggle the item's Equipped state I'd like to "see" what a character's got going on without having to open the "information" layer for each item on the character sheet (or without even opening the sheet). For characters who are repeatedly equipping/stowing shields or donning disguises all the time, it can be quite onerous to determine all the inventory items acting on the character sheet -- especially if you've got a group of players who pick up every stick they come across in the daggone forest.
Try this out <a href="https://gist.github.com/oukag/bf92a517e7dfb2f1ce94b0e46e695d92" rel="nofollow">https://gist.github.com/oukag/bf92a517e7dfb2f1ce94b0e46e695d92</a>
Hey, tried this out, but it doesn't do anything. Did it work for you? Regards
Did you run either of the two commands? !equipShow with a selected token !equipToggle --charid|@{selected|character_id} --item|&lt;ITEM_NAME&gt;
Thanks Kyle. This is really great. The script is properly displaying all the Equipped items. However, using the !equipToggle, or clicking an item name in the !equipShow list does not seem to be toggling all the necessary attributes in the inventory. The script is tripping the equipflag (greying out the item in the inv list), but not the check box, and it is not removing the item mod affects (e.g. AC bonus). Then all these states are weirdly out of sync. This is the same challenge I encountered while trying to figure out the Equipment toggler system in my console tests. -- where toggling the flag doesn't have a cascading affect on all the related attribute states & in the sheet html, the way it does when you trigger them through the sheet itself.
Thanks for pointing that out, I'll see what I can do. The checkbox is a simple fix (I didn't realize there were two attributes that govern if an item is equipped or not), but I get the feeling that the auto-update for ac and such will require recreating the update process in the script rather than tricking the character sheet into think that it was manually changed.
1503681029
Jakob
Sheet Author
API Scripter
Kyle G. said: Thanks for pointing that out, I'll see what I can do. The checkbox is a simple fix (I didn't realize there were two attributes that govern if an item is equipped or not), but I get the feeling that the auto-update for ac and such will require recreating the update process in the script rather than tricking the character sheet into think that it was manually changed. If you use attr.setWithWorker() instead of attr.set(), it should work properly.
Jakob said: If you use attr.setWithWorker() instead of attr.set(), it should work properly. That's awesome. I normally work with custom attributes so I didn't even know that setWithWorker existed. Alright Chris, try it now
On it!
Ok I've tested the new version. Switching to setWithWorker has solved the syncing issue, so now toggling the eq fires all the relevant sheet attributes. Here is what's happening now: activate the script with !equipShow -- I get the right list of equipped items displayed in chat When clicking an item in the chat output list of equipped items, the script reports that the character "has equipped the item." (the item's equip status is not changed). So the first toggling does not change the eq equipped state. Curiously, if I click again, the script does unequip the item, and it properly reports that the item is unequipped, with all the display attributes in sync. It's nearly working!
Alright, that change should have fixed it. I made the comparison to see if the item is equipped a little bit more lax. The character sheet requires that it be a string rather than a number, but for some reason the value is a number and not a string by default.&nbsp;
1503735297

Edited 1503735350
Kyle G. said: Did you run either of the two commands? !equipShow with a selected token !equipToggle --charid|@{selected|character_id} --item|&lt;ITEM_NAME&gt; Hey,&nbsp; yes I did. Had to set up the token again and now it works : ) Is there a way to add new items via macro? Regards
Hey Kyle, I tested the script with a bunch of use situations, and it's working great. Would you mind switching the chat output so everything is whispered?
pale81 said: Kyle G. said: Did you run either of the two commands? !equipShow with a selected token !equipToggle --charid|@{selected|character_id} --item|&lt;ITEM_NAME&gt; Is there a way to add new items via macro? You could do that with ChatSetAttr and setting the individual attributes for the item, but I'll see how much work is required to condense it into a single command.&nbsp; Chris said: Would you mind switching the chat output so everything is whispered? Done
I tried it with ChatSetAttr a few weeks ago. I get it&nbsp;to work, but only with a special "Inventory" attribute, not with the "regular" Inventory.
Thanks Kyle. This is excellent!
1503853093
Jakob
Sheet Author
API Scripter
pale81 said: I tried it with ChatSetAttr a few weeks ago. I get it&nbsp;to work, but only with a special "Inventory" attribute, not with the "regular" Inventory. !setattr [--sel | --charid &lt;ids&gt; | --name &lt;names&gt; | ...] {{ --repeating_inventory_-create_itemname|Stuff --repeating_inventory_-create_itemcount|5 --repeating_inventory_-create_itemweight|7 }}
1503941003

Edited 1503941177
Holy Shit, I tried a lot of things and waste a lot of time and it's that easy? I feel really stupid ; ) Is there a way to do the same for the attack & spell section above the inventory? Regards
Yup, you just have to use know the attributes for the attack and spell. You can find the attributes by looking at the code for the 5e OGL character sheet on the Roll20 github and looking for the specific sections (repeating_attack and repeating_spell-SPELLLEVEL). Note that spells are different than items and attacks because the attribute names also include the spell level. For example repeating_spell-cantrip_ROWID or repeating_spell-1_ROWID
Very nice, i‘ll have to try that thank you all
Nice little script! One other enhancement that could be useful, check status of a single item, something like this ... !equipShow –item|&lt;ITEM_NAME&gt;
Hey,&nbsp; is there a way to change (not only to create) item attributes? !setattr [--sel | --charid &lt;ids&gt; | --name &lt;names&gt; | ...] {{ --repeating_inventory_-create_itemname|Stuff --repeating_inventory_-create_itemcount|5 --repeating_inventory_-create_itemweight|7 }} Used this to create them, but how to change for example the stuff item count to 4 afterwards, with an macro? Thank you and regards
Mark R. said: Nice little script! One other enhancement that could be useful, check status of a single item, something like this ... !equipShow –item|&lt;ITEM_NAME&gt; Just noticed your comment, I have added this functionality to the latest revision. Sorry for taking so long. pale81 said: Hey,&nbsp; is there a way to change (not only to create) item attributes? !setattr [--sel | --charid &lt;ids&gt; | --name &lt;names&gt; | ...] {{ --repeating_inventory_-create_itemname|Stuff --repeating_inventory_-create_itemcount|5 --repeating_inventory_-create_itemweight|7 }} Used this to create them, but how to change for example the stuff item count to 4 afterwards, with an macro? Thank you and regards Yes, you would simply replace -create in repeating_inventory_-create_ATTR with the row ID of the item you are modifying. I believe that Jakob has even accounted for putting the in index ($X) for the row ID if you prefer to not have to find the row ID first. As for whether I would add that functionality to this script, probably not. There are a number of other scripts that can be utilized for such a task. The 5e OGL companion can keep track of resources and you could also use The Aaron's Ammo script I believe.
Awesome, thanks!&nbsp; I have a macro for players that calls this script to don/doff a shield (which auto adjusts their AC).&nbsp; !equipShow –item|shield will let them check current status.
Looks like the latest version is no longer outputting to chat.&nbsp; Is that intended?
No, are you getting any errors?
No errors, but after investigating it's just for one of my campaigns; un-Equips/Equips the item but does not output to chat. I guess I have an api conflict for the one but not the others. But, have the same scripts implemented. The original script does output to chat in the problem campaign, but not the latest script. Strange.