mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
feat(#901): ability to lock seed in templates editor
This commit is contained in:
parent
425325888e
commit
f20029eac5
5 changed files with 14 additions and 12 deletions
|
|
@ -452,7 +452,7 @@ function unlock(id) {
|
|||
// check if option is locked
|
||||
function locked(id) {
|
||||
const lockEl = document.getElementById("lock_" + id);
|
||||
return lockEl.dataset.locked == 1;
|
||||
return lockEl.dataset.locked === "1";
|
||||
}
|
||||
|
||||
// return key value stored in localStorage or null
|
||||
|
|
|
|||
|
|
@ -1041,8 +1041,10 @@ function editHeightmap(options) {
|
|||
const steps = byId("templateBody").querySelectorAll("#templateBody > div");
|
||||
if (!steps.length) return;
|
||||
|
||||
const seed = byId("templateSeed").value;
|
||||
if (seed) Math.random = aleaPRNG(seed);
|
||||
const currentSeed = byId("templateSeed").value;
|
||||
const seed = (locked("templateSeed") && currentSeed) || generateSeed();
|
||||
Math.random = aleaPRNG(seed);
|
||||
byId("templateSeed").value = seed;
|
||||
|
||||
grid.cells.h = createTypedArray({maxValue: 100, length: grid.points.length});
|
||||
HeightmapGenerator.setGraph(grid);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue