cyrb128 string seeds
This commit is contained in:
parent
3bc7961010
commit
61df43961c
|
|
@ -13,7 +13,7 @@ if(enabledMods.includes(variablesMod)) {
|
||||||
};
|
};
|
||||||
|
|
||||||
if(enabledMods.includes("mods/code_library.js")) {
|
if(enabledMods.includes("mods/code_library.js")) {
|
||||||
commandHelpObject.stars = "Clears the screen and replaces it with random stars. Usage: stars <density (number, default: 0.001)> <seed (number, no default value)>\nDon't include framing characters <>.\nArguments in <angle brackets> are optional."
|
commandHelpObject.stars = "Clears the screen and replaces it with random stars. Usage: stars <density (number, default: 0.001)> <seed (string or number, no default value)>\nDon't include framing characters <>.\nArguments in <angle brackets> are optional."
|
||||||
commandHelpObject.starseed = "Alerts the last used seed for stars. Usage: starseed";
|
commandHelpObject.starseed = "Alerts the last used seed for stars. Usage: starseed";
|
||||||
var lastStarSeed = "[None]";
|
var lastStarSeed = "[None]";
|
||||||
};
|
};
|
||||||
|
|
@ -410,21 +410,26 @@ if(enabledMods.includes(variablesMod)) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
if(seed == undefined) {
|
var stringSeed = false;
|
||||||
seed = null;
|
var seedString = null;
|
||||||
|
|
||||||
|
if(seed === undefined) {
|
||||||
|
seed = Math.random();
|
||||||
|
stringSeed = false;
|
||||||
} else {
|
} else {
|
||||||
seed = parseFloat(seed);
|
if(isNaN(parseFloat(seed))) {
|
||||||
if(isNaN(seed)) {
|
stringSeed = true;
|
||||||
alert("seed was NaN, ignoring");
|
seedString = seed;
|
||||||
seed = null;
|
seed = cyrb128(seed)[2];
|
||||||
|
} else {
|
||||||
|
stringSeed = false;
|
||||||
|
seed = parseFloat(seed);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
if(seed == null) {
|
lastStarSeed = stringSeed ? seedString : seed;
|
||||||
seed = Math.random();
|
//console.log(stringSeed);
|
||||||
};
|
//console.log(lastStarSeed);
|
||||||
|
|
||||||
lastStarSeed = seed;
|
|
||||||
var randomFunction = mulberry32(seed);
|
var randomFunction = mulberry32(seed);
|
||||||
|
|
||||||
if(!enabledMods.includes("mods/code_library.js")) {
|
if(!enabledMods.includes("mods/code_library.js")) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue