From f67113cf28481def9b328effdf4e940c9918d6cb Mon Sep 17 00:00:00 2001 From: Lily-129 <68935009+Lily-129@users.noreply.github.com> Date: Sat, 30 Apr 2022 16:47:08 -0400 Subject: [PATCH] rockString uses query, bounds alert() same as previous commit --- mods/random_rocks.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/mods/random_rocks.js b/mods/random_rocks.js index b62aaba7..405f4b9b 100644 --- a/mods/random_rocks.js +++ b/mods/random_rocks.js @@ -6,11 +6,22 @@ if(urlParams.get('rockAmount') != null) { //null check rockAmount = 10 } rockAmount = parseInt(rockAmount) + if(rockAmount > 10000) { + alert("Maximum amount of rocks is 10000.\nOnly 10000 rocks were added.") + } else if(rockAmount < 1) { + alert("Minimum amount of rocks is 1.\n1 rock was added.") + } rockAmount = Math.min(10000,Math.max(rockAmount,1)) } else { rockAmount = 10 } +if(urlParams.get('makeRockString') !== null) { //if the variable exists at all + makeRockString = true +} else { //if it doesn't (and it returns null) + makeRockString = false +} + function _randomInt(max) { if(max >= 0) { return Math.floor(Math.random() * (max + 1)) @@ -29,9 +40,6 @@ const vowelArrayR = ["a","e","i","o","u","ay","ee","ie","oa","ew","oo","oi","ow" const medialArrayR = ["m","n","p","t","k","b","d","g","f","th","s","sh","h","l","r","y","z","sp","st","sk","sl","spl","stl","skl","sr","spr","str","skr","sl","fl","fr","pl","pr","tl","tr","kl","kr","shr","fl","fr","thr"] //:eggTF: const finalArrayR = ["m","n","p","t","k","b","d","g","f","th","s","sh","l","r","y","z","sp","st","sk","sl","spl","stl","skl","sr","spr","str","skr","pl","pr","tl","tr","bl","vr"] //:eggTF: -enabledMods.includes("mods/log_rocks.js") ? logRocks = true : logRocks = false -//This is intended for people who want to copy their rocks from the console to a file for some reason. Technically, the empty enabler script doesn't even have to exist, but I'll make it just so that index.html doesn't spit out an ERR_FILE_NOT_FOUND. - function generateName() { //these are picked arbitrarily @@ -219,7 +227,7 @@ function avgRndToMult() { elements.gravel.breakInto = "dust" -if(logRocks == true) { +if(makeRockString == true) { rockString = "" } @@ -244,7 +252,7 @@ for(i = 0; i < rockAmount; i++) { breakInto: ["dust",`${name}_gravel`], } - if(logRocks == true) { + if(makeRockString == true) { rockString = rockString + `elements.${name} = {\n name: \"${name}\",\n color: [\"${colors[0]}\", \"${colors[1]}\", \"${colors[2]}\"],\n behavior: behaviors.POWDER,\n tempHigh: ${950 * meltingAdjustment},\n category: \"random rocks\",\n state: \"solid\",\n density: ${2550 * densityAdjustment},\n hardness: ${0.5 * hardnessAdjustment},\n breakInto: [\"dust\",\"${name}_gravel\"],\n};\n\n` } @@ -261,12 +269,12 @@ for(i = 0; i < rockAmount; i++) { breakInto: "dust", } - if(logRocks == true) { + if(makeRockString == true) { rockString = rockString + `elements.${name}_gravel = {\n name: \"${name} gravel\",\n color: [\"${colors[3]}\", \"${colors[4]}\", \"${colors[5]}\", \"${colors[6]}\"],\n behavior: behaviors.POWDER,\n tempHigh: ${950 * meltingAdjustment},\n stateHigh: \"${name}\",\n category: \"random rocks\",\n state: \"solid\",\n density: ${1680 * densityAdjustment},\n hardness: ${0.2 * (hardnessAdjustment ** (2/3))},\n breakInto: \"dust\",\n};\n\n` } } -if(logRocks == true) { +if(makeRockString == true) { console.log(`Rocks added to rockString (length ${rockString.length})`) }