Update 'inventory_monitor.js'

Force file updates to only apply when changes are detected.
master
sigonasr2 2 years ago
parent 5fd5ab2c91
commit 66b558991c
  1. 18
      inventory_monitor.js

@ -10,6 +10,8 @@ itemCache={}
retainerIDs=[1572880,16,2359328,131092,9,0,13,1048586,2162700]
retainerInventories=[[],[],[],[],[],[],[],[],[]]
lastDisplayString=""
function getRetainerIndex(id){
switch(id){
case 65576:{
@ -102,12 +104,22 @@ function update(){
await getItemData(itemObj)
var fileData=fs.readFileSync("goalamt.txt")
if (fileData!=0){
fs.writeFile("amt",itemObj.name+": "+tempLineAmt+"/"+fileData+" ("+Math.min(100,Math.floor(tempLineAmt/Number(fileData)*100))+"%)",()=>{})
tempString=itemObj.name+": "+tempLineAmt+"/"+fileData+" ("+Math.min(100,Math.floor(tempLineAmt/Number(fileData)*100))+"%)"
if (lastDisplayString!=tempString){
fs.writeFile("amt",tempString,()=>{})
lastDisplayString=tempString
}
} else {
fs.writeFile("amt","",()=>{})
if (lastDisplayString!=""){
fs.writeFile("amt","",()=>{})
lastDisplayString=""
}
}
} else {
fs.writeFile("amt","",()=>{})
if (lastDisplayString!=""){
fs.writeFile("amt","",()=>{})
lastDisplayString=""
}
}
}
itemID=item[1]

Loading…
Cancel
Save