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 HELP] Inventory Management - Doff and Don macro

1622562832

Edited 1622562851
Hello Script Wizards! I am looking for an inventory management script that will let me toggle equipped items with a macro, specifically a shield that is frequently doffed and donned.  I have tried Kyle G.'s 5e OGL tracker:  Community Forums: [API] List and Toggle Equipment (5e OGL) | Roll20: Online virtual tabletop but it does not seem to work. It gives me this when run: I do not want a graphical system, just something that will let me tick and untick the Equipped box on inventory with a macro. Any thoughts or help would be most appreciated!
1622564303
The Aaron
Roll20 Production Team
API Scripter
The worn check mark is just an attribute. You should be able to toggle it with ChatSetAttr. The complicated part is getting its name. It might show on a hover, or you might need to inspect it in the developer console. Once you have it, you'll need to either refer to it explicitly with the row ID or implicitly with the row offset using $. 
1622565842
timmaugh
Pro
API Scripter
Fetch can retrieve it, too. It can retrieve it once, so you can copy and use it going forward, or it can retrieve it each time, inline.
@The Aaron - I have the RowID, but for the life of me I cannot find the syntax for altering repeating item attributes. This is what I have worked out using the inspector: !setattr --sel --repeating_inventory_-MazzO8sPCODekrcA0cf_attr_equipped|[0/1] I have also tried !setattr --sel --repeating_inventory_-MazzO8sPCODekrcA0cf_attr_equipped_equippedflag|[0/1] and !setattr --sel --repeating_inventory_$2_attr_equipped|[0/1] Each of these iterations output that the change has been made, but does not actually change the check in the box. What am I doing wrong?
Somehow, my tinkering with ChatSetAttr made InventoryTracker work. I must have created an attribute that InventoryTracker could manipulate that it couldn't before. I have no idea what I did, but it now works.
1622777033
timmaugh
Pro
API Scripter
The attribute you're looking for is: repeating_inventory_-MazzO8sPCODekrcA0cf_equipped You could enter the following into chat and get a value (with a valid character name): @{character|repeating_inventory_-MazzO8sPCODekrcA0cf_equipped} Now, to get that, you had to go to the inspector. To get it with Fetch, you could do something like: *(character.inventory.[itemname~Backpack].equipped) That would get the equipped value for the item whose name included the text, "Backpack". To use it in the ChatSetAttr call you had, just above, you would want to return the name of the repeating element. That would be: *(character.inventory.[itemname~Backpack].equipped.name) Fetch lets you use a more intuitive, in-game syntax to get the thing you're after. ... Oh, and in testing this out, I ran into a situation where I couldn't retrieve the equipped attribute with Fetch until after I had cycled the checkbox on the character sheet. I will be looking to put a workaround into Fetch for that, but I wonder if you had something similar going on when the Toggle script wasn't working for you...?
@timmaugh That was exactly it. When testing the Inventory script on other characters, I noticed only items I had recently equipped showed up. So toggling everything in their inventory on and off made it show up for the script. Problem solved. However, I do greatly appreciate the guidance on that syntax for chatsetattr. It was the repeating_inventory_<repeatingrowID>_equipped that was getting me. I was trying to treat it like a repeating resource, which has a slightly different syntax. So thanks for that. One day I will learn how to use your Fetch script.