1
0
Fork 0
mirror of https://github.com/thepaperpilot/The-Modding-Tree.git synced 2025-05-10 20:11:30 +00:00

NaNs are handled

This commit is contained in:
Acamaeda 2020-10-27 17:41:35 -04:00
parent 9bfe0fc3d3
commit de17f38f2f
5 changed files with 55 additions and 9 deletions

View file

@ -241,6 +241,38 @@ function load() {
loadVue();
}
function fixNaNs() {
NaNcheck(player)
}
function NaNcheck(data) {
for (item in data){
if (data[item] == null) {
}
else if (Array.isArray(data[item])) {
NaNcheck(data[item])
}
else if (data[item] !== data[item] || data[item] === decimalNaN){
if (NaNalert === true || confirm ("Invalid value found in player, named '" + item + "'. Please let the creator of this mknow! Would you like to try to auto-fix the save and keep going?")){
NaNalert = true
data[item] = (data[item] !== data[item] ? 0 : decimalZero)
}
else {
clearInterval(interval);
player.autosave = false;
NaNalert = true;
}
}
else if (data[item] instanceof Decimal) { // Convert to Decimal
}
else if ((!!data[item]) && (data[item].constructor === Object)) {
NaNcheck(data[item])
}
}
}
function exportSave() {
let str = btoa(JSON.stringify(player))