From 14a157b7e38a3668f18a0addbc38474790548ae4 Mon Sep 17 00:00:00 2001 From: "sigonasr2, Sig, Sigo" Date: Tue, 16 Aug 2022 13:25:13 +0000 Subject: [PATCH] Records now come from a file instead --- data | 6 ++++++ index.js | 33 +++++++++++++++++++++++++++------ run.sh | 3 +++ 3 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 data create mode 100755 run.sh diff --git a/data b/data new file mode 100644 index 0000000..e6184cb --- /dev/null +++ b/data @@ -0,0 +1,6 @@ + +886 +38 +8921 +886 +sigonasr2 diff --git a/index.js b/index.js index 6440235..e3574f4 100644 --- a/index.js +++ b/index.js @@ -18,18 +18,31 @@ const newSnake = require('./wrapper.js') const dotenv = require('dotenv'); dotenv.config(); +const fs = require('fs'); + let snake = newSnake(process.env.auth) // Login with the auth cookie in the secrets tab +var vals = fs.readFileSync("data", 'utf8').split("\n") + +/*File Format: +`${LAST_DEATH} +${BEST_LENGTH} +${TOTAL_ATTEMPTS} +${TOTAL_LENGTH} +${BEST_SEEN} +${BEST_SEEN_WHO} +` +*/ horz_dir = LEFT vert_dir = UP -LAST_DEATH = "" -BEST_LENGTH = 744 -TOTAL_ATTEMPTS = 37 -TOTAL_LENGTH = 8066 +LAST_DEATH = vals[0] +BEST_LENGTH = vals[1] +TOTAL_ATTEMPTS = vals[2] +TOTAL_LENGTH = vals[3] LAST_LENGTH = 0 -BEST_SEEN = 764 -BEST_SEEN_WHO = "Bot 2578" +BEST_SEEN = vals[5] +BEST_SEEN_WHO = vals[6] TEST_REGIONS = [] APPLES_LIST=[] targetApp={} @@ -43,6 +56,14 @@ snake.onDeath = function(reason) { // When the snake dies LAST_DEATH = reason TOTAL_LENGTH += LAST_LENGTH LAST_LENGTH = 0 + fs.writeFileSync("data", + `${LAST_DEATH} + ${BEST_LENGTH} + ${TOTAL_ATTEMPTS} + ${TOTAL_LENGTH} + ${BEST_SEEN} + ${BEST_SEEN_WHO} + `) snake.spawn() // Respawn } diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..923f2e5 --- /dev/null +++ b/run.sh @@ -0,0 +1,3 @@ +while [ 1 ]; do +node index.js +done \ No newline at end of file