Skip to content

Commit

Permalink
Added automatic replay downloading, fixed default.rpl being deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
HunterBoy344 authored Jun 17, 2024
1 parent 1744182 commit 1790380
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ connectbutton.addEventListener("click", function(event) {
});
tracksToDelete = filesArray.filter(element => element.includes(".RPL"));
tracksToDelete.forEach((element, index) => {
if (element != 'DEFAULT.RPL') {
if (element.toUpperCase() != 'DEFAULT.RPL') {
FS.unlink(`/${element}`)
}
});
Expand All @@ -40,7 +40,7 @@ connectbutton.addEventListener("click", function(event) {
});
tracksToDelete = filesArray.filter(element => element.includes(".rpl"));
tracksToDelete.forEach((element, index) => {
if (element != 'DEFAULT.RPL') {
if (element.toUpperCase() != 'DEFAULT.RPL') {
FS.unlink(`/${element}`)
}
});
Expand Down Expand Up @@ -249,13 +249,24 @@ function getReplayFromFS() {
console.log('Automatically sent replay!')
FS.unlink('/DEFAULT.RPL')
} */

// Check for highscore files
var replayCheck = FS.analyzePath(`/${trackName}.HIG`)
if (replayCheck.exists == true) {
var replay = FS.readFile(`/${trackName}.HIG`, { encoding : 'binary' })
ws.send(`{"replay" : "${_arrayBufferToBase64(replay.buffer)}", "username" : "${username}", "ID" : "${ID}" }`)
console.log('Automatically sent replay!')
FS.unlink(`/${trackName}.HIG`)
}

// Check for replay files
let filesArrayCheck = FS.readdir('/');
let replaysToSave = filesArrayCheck.filter(element => element.includes(".RPL"));
replaysToSave.forEach((element, index) => {
if (element.toUpperCase() != 'DEFAULT.RPL') {
downloadFile(element);
}
});
}

function msToTime(s) {
Expand Down

0 comments on commit 1790380

Please sign in to comment.