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] Inventory Extension / Card Token Saver

1396116771

Edited 1396808901
<a href="https://gist.github.com/Parmeisan/fc5827ed55081a81" rel="nofollow">https://gist.github.com/Parmeisan/fc5827ed55081a81</a>... What Does it Do? This script keeps track of changes that you make to cards that are on the table as tokens. When you move it into your hand, it saves the state. When you drop it back on the table, it loads it. Reset the card by dragging it directly to the table. Note: It can also keep track of text & paths drawn onto the card, but this feature is turned off by default because, due to limitations within the API, it only works to load these to the same page they were saved from , and you have to manually use "send to back" on the card each time it's loaded [fixed] . Turn this on by setting saving_graphics to true. (It's about the fourth variable in the script.) Why Do You Want It? It lets you extend the use of cards so that you can do various things with them and have the game remember. For example, maybe you are using decks for your Inventory and you want to be able to keep track of durability or ammo. (PS. This script is a response to this discussion ). Example Behold: <a href="http://agile-games.net/misc/images/inv_ext_screenc" rel="nofollow">http://agile-games.net/misc/images/inv_ext_screenc</a>... (The gif animation doesn't show up if I put it directly in the post, so it's a link instead. You can't really get the effect with a still image, but I'll include a couple anyway because who doesn't like pictures?) This example has saving_graphics turned on, so that I didn't have to make two examples. Usage: The saving and loading happens automatically when cards are moved to or from the tabletop. Clear card data with: !inv clear-all (All saved cards) !inv clear-this (Selected cards only.) Updates & To-Do: (as of March 29, 2014) [FUTURE] As soon as the API supports it, fix the issues with saving graphics and paths, then make that behaviour standard. [UPDATED] Manual send-to-back no longer necessary. [UPDATED] Made everything a little more robust; save & load no longer depends on your hand in any way. Consequently, added chat commands to clear out your saved cards. [TODO] A chat command to clear out a particular deck only. Possibly a preference for auto-clearing decks on shuffle.
There are toBack() and toFront() api commands now. That would solve the issue with having to right click and send to back.
Are there?? Well, let me go update that right now . Thanks!
...They're on the dev server only, aren't they? I'm getting "TypeError: Object [object Object] has no method 'toBack' at ...."
You have to use the object id, not the object itself.
Ah, it appears that you do use the object itself, just not in the way I was trying it: toBack(copy_dest); (and not copy_dest.toBack()). Thanks for the help! The script has been updated.
Cool. No problem.
Robert R. said: I tried running this. I set a card's bar 1 and attached to a character token. Then I picked it up and put it back down. It forgot everything. What am I doing wrong? Robert, Chances are decent that it's something I'm doing wrong, as it sounds like it should handle that scenario. One question - did the card originally get set on the table prior to the script being installed? When I do it that way, the script fails, but otherwise when I try it, it works. Whether that's what happened to you or not, that's definitely a situation I should fix. I'll see if I can put out an update today. If that's not it - do you think you could change "debugging" (on the 2nd line if you ignore comments) to "true", and then run through this again and then PM me the resulting log? parm_inv_ext.debugging = true; Thanks!!
Revised version on GitHub now: Loads/saves when the card is added/removed from the table, regardless of whether it was ever in your hand. This also just generally makes it more robust in a few different ways. Chat command "!inv clear-all" clears out all data for all saved cards. Chat command "!inv clear-this" sets all selected card's data (except width, height, image, top, left, layer, and read-only attributes) to empty and removes their saved data. Let me know if this fixes your issues!
This worked perfectly on everything for a few hours. Then I let them sit in my character's hand overnight, and by morning they forgot everything.