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 Manager, Slim

Inventory Manager Slim This is a slimmed down and modified version of Rouby's adaptation of John C's Graphic Inventory Manager. The overall setup follows  Rouby's instructions with the following differences: All warmth components are removed. All volume components are removed. Tinting of liquid containers is removed. The attribute "status3" is not used. Storage items can have one or more Type attributes which auto-populate to the gm_notes field when the item is first placed in a Equipment Slot (e.g. "constantweight", "unstowable"). If a storage item with the attribute "liquid" has a bar1_ value of 0, it will display "Empty" in the name field. If a storage item with the attribute "liquid" has a bar1_value that is not 0 and contains "Empty" in the name field, its name field changes to "????". A Status Marker token with the attribute "status" will display the total weight value along with a load level description (e.g. "Light", "Medium", "Heavy"). A Status Marker token with the attribute "status2" will display the summed gold piece equivalent value of all the inventory tokens with the attribute of "coin [type]" as long as they are anywhere within the Character Area (map token with attribute "main") not only those connected to an Equipment Slot (map token with attribute "worn"). This allows for coins to be stored unworn storage containers such as chests. The following are D&D 3.5 specific tweaks which can be easily modified: Electrum piece has been removed as a coin type. Bag of Holding Types I, II, III, and IV attributes are predefined. The load levels are calculated according to D&D 3.5 rules
Derek, I'm actually using the original script, but there's a couple things I don't like about it, so I'm testing this one out.  I will want to tweak some of the 3.5 things, but that's later.  Right now, I can't seem to get the coins to come up with the correct names.  I have (for example) "coins copper" (no quotes, space in between the words, no underscore) in the GM notes, and I put the number of coins in and the weight calculates correctly in Bar 1, but the name shows up as "undefined:20" (in this example, I put in 20 coins).  What am I doing wrong? EDIT:  Ok, I see that the script seems to require "coin copper" not "coins copper", but I'm still getting the undefined name for coins.  and NaN in the status2 marker.
For my version, the correct GM notes is "coins copper". Make sure you have the display name set in the localization section of the script.
Ok, but at the top of the script, the localization has this: var Localization = { 'coins': 'GP Equiv', 'coin_copper': 'CP', 'coin_silver': 'SP', 'coin_gold': 'GP', 'coin_platinum': 'PP', is that correct?  EDIT: Just tried it, and it's still giving me "undefined" as the name for the coins.  I've made changes to the user configuration area, and added Electrum pieces back in, just FYI, don't know if that makes a difference.
I'm still not able to get the coins to work.  Any chance I could get some help with this?
Sure. What have you done so far?
Here's what I did for the localization part of the script: var Localization = { 'coins': 'GP Equiv', 'coin_copper': 'CP', 'coin_silver': 'SP', 'coin_electrum': 'EP', 'coin_gold': 'GP', 'coin_platinum': 'PP', 'weight': 'Weight', 'loadLvl1': 'Move: 120', 'loadLvl2': 'Move: 90', 'loadLvl3': 'Move: 60', 'loadLvl4': 'Move: 30', 'empty' : 'Empty', 'storage_backpack': 'Backpack', 'storage_smallquiver': 'Quiver - 12 Arrows', 'storage_largequiver': 'Quiver - 24 Arrows', 'storage_smallpouch': 'Sm. Pouch', 'storage_smallsack': 'Sm. Sack', 'storage_largepouch': 'Lg. Pouch', 'storage_bagofholding': 'Bag of Holding', 'storage_largesack': 'Lg. Sack', 'storage_satchel': 'Satchel', 'storage_chest': 'Chest', 'storage_cart': 'Cart' }; And then the rest of the user configuration (apart from player ids): coin: { weight: 0.1, // in lbs value_copper: 0.01, value_silver: 0.1, value_electrum: 0.5, value_gold: 1, value_platinum: 5 }, storageItems: [ { name: 'backpack', // key of the storagekind, does not contain storage! maxWeight: 30, // maximum weight allowed in this kind type: '' // if bag of holding (or similar), then ' constantweight; if large container, then ' unstowable' }, { name: 'smallquiver', maxWeight: 4, type: '' }, { name: 'largequiver', maxWeight: 8, type: '' }, { name: 'smallpouch', maxWeight: 2.5, type: '' }, { name: 'smallsack', maxWeight: 10, type: '' }, { name: 'largepouch', maxWeight: 5, type: '' }, { name: 'bagofholding', maxWeight: 500, type: ' constantweight' }, { name: 'largesack', maxWeight: 40, type: '' }, { name: 'satchel', maxWeight: 10, type: '' }, { name: 'chest', maxWeight: 300, type: ' unstowable' }, { name: 'cart', maxWeight: 600, type: ' unstowable' } ], Sorry for the wall of text, I don't know how to format it as code without the line breaks messing it up. Here's a picture of what happens: The coin value calculates correctly, but the names show up as undefined, and the "GP equiv" does not calculate.
When you set up a coin inventory object, what do you put in the gmnotes field?
coins copper (or whatever the coin name is):
Given the "undefined: #" names, I think there is something preventing the tokens from processing correctly as coin tokens. The only difference I see between the way you set it up I set it up is the "Represents Character" field. Mine remains set as None/Generic Token. Try creating a clean coin token with that setting.
Yes, I thought of that, and did that, but got the same result.
In the inventory page screenshot are they in a "coin purse" storage area? I don't see that as one of the storage types you defined in your user config.
It's a small pouch, I just changed the name after it was created.  But it does the same thing, even if they coins are not in a storage area.
Let's work on one issue at a time. The coin values are calculating, but the totalCoinValue is not. The line that calculates this is: totalCoinValue = charArea.containedCoinValue.toFixed(1) Is your Character Area container set up correctly?
The settings for the Character Area are as follows: You didn't ask, but it case it's the next question, the status token for coins is set up as follows (i need to change the look of it, but that shouldn't matter for coin calculation):
Is the Character Area container sized large enough and place on the correct layer?
Yes, it's on the map layer, and stretches across the page.
Just as an experiment, I tried creating a brand new token for the Coin Value status (status2), but got the same result:
The only other thing I see (and I don't know why it would make a difference) is you added electrum back into the use config. Try commenting that config line out.
No dice.  That didn't help, still the same result. 
Ok. So clearly thes lines: if (itemIsInContainer(item.graphic, charArea.graphic) && item.properties.coinType) // new addition { charArea.containedCoinValue += SlimInventoryManager.coin['value_' + item.properties.coinType] * item.properties.coinAmount; } is returning a Not a Number result. The question is why. The "undefined" in the Coin token name fields indicates that this line: item.graphic.set('name', Localization['coin_' + item.properties.coinType] + ': ' + item.properties.coinAmount); is not returning the correct user localization string for coinType. The coinType is defined by this line: coinType: paramModifier.coins, which should be parsing the gmnotes field for the word "coins" and the descriptor that follows. It does so correctly in my campaign. If something is preventing the script for correctly identifying the Coin tokens as coinType, then their value would never be added to the containedCoinValue.  Question to you: can you determine if the coin weights are being calculated correctly?
Yes, the coin weights are being calculated correctly.  That is a part that I changed, since coins weigh more in 1e than in 3.5, but it's calculating the weight and adding it to the status token correctly.
Everything is pointing back to something that is preventing the script from properly parsing out the gmnotes of your coin tokens such that it identifies them as the correct coin type. I think it knows that they are coin type objects and therefore calculates the weights correctly. That means it is parsing out the "coins" string in the gmnotes. What is failing the parsing of the copper, silver, electrum, etc. I've looked over the code sample you posted line by line and don't see an error in your configs. It has to be an issue with the set up of the coin tokens themselves. Can you invite me into the campaign where the script is implemented as a co-GM?
Link sent via PM.