From d28748376e78b245c2eb77daa958cf8e0dcdecd2 Mon Sep 17 00:00:00 2001 From: Lily-129 <68935009+Lily-129@users.noreply.github.com> Date: Fri, 8 Apr 2022 10:17:01 -0400 Subject: [PATCH] liquidAmount sets the amount of generated liquids It works like the "rockAmount" parameter in the rock mod. "?liquidAmount=100" will produce 100 randomly generated solid-liquid-gas triplets. With both mods enabled, passing "?rockAmount=76&liquidAmount=42" will make the mods generate 76 rock-gravel pairs and 42 SLG triplets. --- mods/random_liquids.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mods/random_liquids.js b/mods/random_liquids.js index 989659ed..cbc813ed 100644 --- a/mods/random_liquids.js +++ b/mods/random_liquids.js @@ -1,3 +1,16 @@ +urlParams = new URLSearchParams(window.location.search); + +if(urlParams.get('liquidAmount') != null) { //null check + liquidAmount = urlParams.get('liquidAmount') + if(isNaN(liquidAmount) || liquidAmount === "" || liquidAmount === null) { //NaN check + liquidAmount = 10 + } + liquidAmount = parseInt(liquidAmount) + liquidAmount = Math.min(10000,Math.max(liquidAmount,1)) +} else { + liquidAmount = 10 +} + function _randomInt(max) { if(max >= 0) { return Math.floor(Math.random() * (max + 1)) @@ -196,7 +209,7 @@ if(logLiquids == true) { liquidString = "" } -for(i = 0; i < 10; i++) { +for(i = 0; i < liquidAmount; i++) { var name = generateName(); var meltingAdjustment = avgRndToMult(); var densityAdjustment = avgRndToMult();