MooingCat

MC Continent Map Cost Script

Feb 24th, 2021 (edited)
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // 1 - change names to (exact) goods names and change number of elements in "goods" to number of goods types
  2. localStorage.setItem("goodstypes", JSON.stringify(["BioTech Crops", "Fusion Reactors", "Lubricant", "Mars Microbes", "Superalloys", "Bromine", "Compound Fluid", "Nickel", "Platinum Crystals", "Processed Materials","Promethium","Orichalcum","Mars Ore", "Asteroid Ice"]))
  3. localStorage.setItem("goods", JSON.stringify([0,0,0,0,0,0,0,0,0,0,0,0,0,0]))
  4.  
  5. // 2 - open each sector you want to include and use following script
  6. var goods = JSON.parse(localStorage.getItem("goods"));
  7. var goodstypes = JSON.parse(localStorage.getItem("goodstypes"));
  8. for(var i = 3; i<document.getElementsByClassName("FoETable")[0].rows.length; i++){
  9.     if(document.getElementsByClassName("FoETable")[0].rows[i].cells[3] == undefined){continue;}
  10.     for(var n = 0; n < document.getElementsByClassName("FoETable")[0].rows[i].cells[3].childNodes.length; n += 2){
  11.         if(document.getElementsByClassName("FoETable")[0].rows[i].cells[3].childNodes[n].alt != undefined){
  12.                     goods[goodstypes.indexOf(document.getElementsByClassName("FoETable")[0].rows[i].cells[3].childNodes[n].alt)] += parseInt(document.getElementsByClassName("FoETable")[0].rows[i].cells[3].childNodes[n+1].data);
  13.         }else{
  14.                     goods[goodstypes.indexOf(document.getElementsByClassName("FoETable")[0].rows[i].cells[3].childNodes[n].childNodes[0].alt)] += parseInt(document.getElementsByClassName("FoETable")[0].rows[i].cells[3].childNodes[n+1].data);
  15.         }
  16.     }
  17. }
  18. localStorage.setItem("goods",JSON.stringify(goods));
  19. localStorage.setItem("goodstypes",JSON.stringify(goodstypes));
  20.  
  21. // 3 - print results
  22. var testgoods = JSON.parse(localStorage.getItem("goods"));
  23. var testgoodstypes = JSON.parse(localStorage.getItem("goodstypes"));
  24. for(var i = 0; i<14; i++){
  25.     console.log(testgoodstypes[i] + ": " + testgoods[i]);
  26. }
  27.  
  28. // 4 - go back to step 2 to continue adding goods, jump to step 1 to reset count
Add Comment
Please, Sign In to add comment