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] retainerIDs=[1572880,16,2359328,131092,9,0,13,1048586,2162700]
retainerInventories=[[],[],[],[],[],[],[],[],[]] retainerInventories=[[],[],[],[],[],[],[],[],[]]
lastDisplayString=""
function getRetainerIndex(id){ function getRetainerIndex(id){
switch(id){ switch(id){
case 65576:{ case 65576:{
@ -102,12 +104,22 @@ function update(){
await getItemData(itemObj) await getItemData(itemObj)
var fileData=fs.readFileSync("goalamt.txt") var fileData=fs.readFileSync("goalamt.txt")
if (fileData!=0){ 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 { } else {
fs.writeFile("amt","",()=>{}) if (lastDisplayString!=""){
fs.writeFile("amt","",()=>{})
lastDisplayString=""
}
} }
} else { } else {
fs.writeFile("amt","",()=>{}) if (lastDisplayString!=""){
fs.writeFile("amt","",()=>{})
lastDisplayString=""
}
} }
} }
itemID=item[1] itemID=item[1]

Loading…
Cancel
Save