rockAmount parameter now sets the amount of rocks

For example, passing "?rockAmount=20" makes the script generate 20 rocks instead of 10. Bounds 1 and 10,000.
This commit is contained in:
Lily-129 2022-04-08 10:08:27 -04:00 committed by GitHub
parent 19f9024698
commit 24b28a2f28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -1,3 +1,16 @@
urlParams = new URLSearchParams(window.location.search);
if(urlParams.get('rockAmount') != null) { //null check
rockAmount = urlParams.get('rockAmount')
if(isNaN(rockAmount) || rockAmount === "" || rockAmount === null) { //NaN check
rockAmount = 10
}
rockAmount = parseInt(rockAmount)
rockAmount = Math.min(10000,Math.max(rockAmount,1))
} else {
rockAmount = 10
}
function _randomInt(max) {
if(max >= 0) {
return Math.floor(Math.random() * (max + 1))
@ -210,7 +223,7 @@ if(logRocks == true) {
rockString = ""
}
for(i = 0; i < 10; i++) {
for(i = 0; i < rockAmount; i++) {
var name = generateName()
var meltingAdjustment = avgRndToMult()
var densityAdjustment = avgRndToMult()