diff --git a/readme.txt b/readme.txt index b7f7372..058fd9c 100644 --- a/readme.txt +++ b/readme.txt @@ -19,4 +19,9 @@ HOW TO USE: === If the program closes as soon as you open it, that means it crashed. -A file called crash_log.txt will be created - send it to Colon and he'll hopefully get around to fixing it. \ No newline at end of file +A file called crash_log.txt will be created - send it to Colon and he'll hopefully get around to fixing it. + +=== + +Mac/Linux/non-Windows users, or if the game is installed in a nonstandard location: +Replace the directory in directory.txt with whereever the game's Resources folder is located on your system, or simply pass it as a command-line argument. diff --git a/shuffle.js b/shuffle.js index 285db96..c64485f 100644 --- a/shuffle.js +++ b/shuffle.js @@ -36,7 +36,10 @@ let iconRegex = /^.+?_(\d+?)_.+/ let forms = assets.forms let sheetList = Object.keys(assets.sheets) let glowName = sheetList.filter(x => x.startsWith('GJ_GameSheetGlow')) -let gdPath = fs.readFileSync('directory.txt', 'utf8') + +// newlines/CRs are usually present in text files, strip them out so they aren't part of the pathname +let gdPath = process.argv[2] ?? fs.readFileSync('directory.txt', 'utf8').replace(/[\n\r]/g, '') + if (!fs.existsSync(gdPath)) throw "Couldn't find your GD directory! Make sure to enter the correct file path in directory.txt" let glowPlist = fs.readFileSync(`${gdPath}/${glowName[0]}.plist`, 'utf8') let sheetNames = sheetList.filter(x => !glowName.includes(x)) @@ -54,7 +57,8 @@ resources.forEach(x => { sheetNames.forEach(x => { let file = fs.readFileSync(`${gdPath}/${x}.plist`, 'utf8') plists.push(file) - sheets.push(plistToJson(file)) + try { sheets.push(plistToJson(file)) } + catch(e) { throw `Error parsing ${x}.plist - ${e.message}` } }) sheets.forEach((gameSheet, sheetNum) => { @@ -134,4 +138,4 @@ console.log("Randomization complete!") } -catch(e) { console.log(e); fs.writeFileSync('crash_log.txt', e.stack ? `Something went wrong! Send this error to Colon and he'll get around to fixing it at some point.\n\n${e.stack}` : e, 'utf8') } \ No newline at end of file +catch(e) { console.log(e); fs.writeFileSync('crash_log.txt', e.stack ? `Something went wrong! Send this error to Colon and he'll get around to fixing it at some point.\n\n${e.stack}` : e, 'utf8') }