Open christopherflora opened 2 years ago
Hello guys,
I'm not a developer for this repository, but I've had the time to fix the current JS for the DnD5e: 1.4.x update. See the code below for refference:
static calculateWeight(inventory, currency) {
let customWeight = 0;
for (let id in inventory) {
let section = inventory[id];
if (section.ignoreWeight !== true) {
for (let i of section.items) {
customWeight += i.totalWeight;
}
}
if (Number(section.ownWeight) > 0) {
customWeight += Number(section.ownWeight);
}
}
let coinWeight = 0
if (game.settings.get("dnd5e", "currencyWeight")) {
let numCoins = Object.values(currency).reduce((val, denom) => val += Math.max(denom, 0), 0);
if(game.settings.get("dnd5e", "metricWeightUnits")){
coinWeight = Math.round((numCoins * 10) / CONFIG.DND5E.encumbrance.currencyPerWeight.metric) / 10;
}else{
coinWeight = Math.round((numCoins * 10) / CONFIG.DND5E.encumbrance.currencyPerWeight.imperial) / 10;
}
}
customWeight += coinWeight;
customWeight = Number(customWeight).toFixed(2);
return customWeight;
}
My branch for refference: https://github.com/ZeroXNoxus/inventory-plus
I added a simple if with in the weight check and removed a console log. I'm currently using my own branch to fix the issue for my game while there is no fix available on the master branch.
I do not take a claim on this project, I just want to help out resolve some issues!
Cheers!
Works perfectly, thank you!
Created a pull request, just waiting for @syl3r86 to merge!
Any news on a fix for this? For now turning currency weight off in the Foundry System settings is the only way to get around this. But I do want currency weight to count towards total weight when my players get enough coin for it to matter.
Just ran into this bug as well. Turning off currency weight will work for now.
Looking forward to the next release to fix this. =)
For the commenters above - ZeroXNoxus' fix works great, and it's pretty easy to pop in yourself if you don't want to wait for the official update. Click on his link "My branch for reference", download his 'inventory-plus.js' file, and replace the existing file on your foundry server with that one (to be safe, keep the old one by renaming it to something like 'inventory-plus.old').
This file will be in your foundry data folder at: Data/modules/inventory-plus
After updating to dnd5e system 1.4.0 today, the total weight bar at the bottom of the inventory tab shows as NaN/300.
This calculation error is happening on actors with custom categories and those without custom categories, as well as on newly created actors.
Disabling inventory+ fixes the error, but the error comes back once Inventory+ is re-enabled.