Browse Source

:v

- Update potion count function from inventory
Fukki 7 years ago
parent
commit
4312b24bc5
2 changed files with 7 additions and 5 deletions
  1. 6 4
      index.js
  2. 1 1
      manifest.json

+ 6 - 4
index.js

@@ -58,12 +58,14 @@ module.exports = function AutoPOT(mod) {
 		if (!inUpdate) {
 			inUpdate = true;
 			for(let i = 0; i < hpPot.length; i++) {
-				gPot = e.items.find(item => item.id === Number(hpPot[i][0]));
-				if (gPot) hpPot[i][1].amount = gPot.amount;
+				gPot = e.items.filter(item => item.id === Number(hpPot[i][0]));
+				if (gPot.length > 0)
+					hpPot[i][1].amount = gPot.reduce(function (a, b) {return a + b.amount;}, 0);
 			}
 			for(let i = 0; i < mpPot.length; i++) {
-				gPot = e.items.find(item => item.id === Number(mpPot[i][0]));
-				if (gPot) mpPot[i][1].amount = gPot.amount;
+				gPot = e.items.filter(item => item.id === Number(mpPot[i][0]));
+				if (gPot.length > 0)
+					mpPot[i][1].amount = gPot.reduce(function (a, b) {return a + b.amount;}, 0);
 			}
 			inUpdate = false;
 		}

+ 1 - 1
manifest.json

@@ -1,6 +1,6 @@
 {
 	"files": {
-		"index.js": "8766efd568ea19609e694e6875148899d24b12797da35d8e536e95c991f5f83e"
+		"index.js": "64932c83dca62ac65644ef5b96b407298b60029e49508ed189f7d1951c0aa6ac"
 	},
 	"defs": {
 		"C_USE_ITEM": 3,