Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Commit

Permalink
Custom directories + crash logging
Browse files Browse the repository at this point in the history
try/catch is OP
  • Loading branch information
GDColon committed Jul 13, 2020
1 parent 18fd474 commit 2e24904
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 0 additions & 2 deletions assets.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"gdPath": "C:/Program Files (x86)/Steam/steamapps/common/Geometry Dash/Resources",

"sheets": {
"FireSheet_01-uhd": 40,
"GauntletSheet-uhd": 50,
Expand Down
1 change: 1 addition & 0 deletions directory.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:/Program Files (x86)/Steam/steamapps/common/Geometry Dash/Resourcesa
17 changes: 12 additions & 5 deletions shuffle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const fs = require('fs')
const plist = require('plist');
const assets = require('./assets.json')

try { // god-tier crash prevention system

Array.prototype.shuffle = function() {
let length = this.length; let unshuffled = this; let shuffled = [];
while (shuffled.length !== length) {
Expand Down Expand Up @@ -31,9 +33,10 @@ let iconRegex = /^.+?_(\d+?)_.+/
let forms = assets.forms
let sheetList = Object.keys(assets.sheets)
let glowName = sheetList.filter(x => x.startsWith('GJ_GameSheetGlow'))
let glowPlist = fs.readFileSync(`${assets.gdPath}/${glowName[0]}.plist`, 'utf8')
let gdPath = fs.readFileSync('directory.txt', 'utf8')
let glowPlist = fs.readFileSync(`${gdPath}/${glowName[0]}.plist`, 'utf8')
let sheetNames = sheetList.filter(x => !glowName.includes(x))
let resources = fs.readdirSync(assets.gdPath)
let resources = fs.readdirSync(gdPath)

let plists = []
let sheets = []
Expand All @@ -45,7 +48,7 @@ resources.forEach(x => {
})

sheetNames.forEach(x => {
let file = fs.readFileSync(`${assets.gdPath}/${x}.plist`, 'utf8')
let file = fs.readFileSync(`${gdPath}/${x}.plist`, 'utf8')
plists.push(file)
sheets.push(plistToJson(file))
})
Expand Down Expand Up @@ -117,10 +120,14 @@ assets.sprites.forEach(img => {
if (spriteMatch[2] == "g2") foundTextures = foundTextures.filter(x => specialGrounds.some(y => x.startsWith(y)))

let shuffledTextures = foundTextures.shuffle()
foundTextures.forEach((x, y) => fs.copyFileSync(`${assets.gdPath}/${x}`, `./pack/${shuffledTextures[y]}`))
foundTextures.forEach((x, y) => fs.copyFileSync(`${gdPath}/${x}`, `./pack/${shuffledTextures[y]}`))
})

let emptyDict = glowPlist.match(/<dict>\s*<key>aliases<\/key>(.|\n)+?<\/dict>/)[0].replace(/{\d+,\d+}/g, "{0, 0}")
let mappedBackups = glowBackups.reverse().map(x => `<key>${x}</key>${emptyDict}`).join("")
glowPlist = fs.writeFileSync('./pack/GJ_GameSheetGlow-uhd.plist', glowPlist.replace(/###/g, "").replace(/<dict>\s*<key>frames<\/key>\s*<dict>/g, "$&" + mappedBackups), 'utf8')
console.log("Randomization complete!")
console.log("Randomization complete!")

}

catch(e) { console.log(e); fs.writeFileSync('crash_log.txt', `Something went wrong! Send this error to Colon and he'll get around to fixing it at some point.\n\n${e.stack}`, 'utf8') }

3 comments on commit 2e24904

@Stazzical
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resourcesa

@GDColon
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resourcesa

i was tesTING invalid directories

@Stazzical
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm

Please sign in to comment.