Use runAfterAutogen to catch molten elements
This commit is contained in:
parent
527754ca15
commit
670abff7c9
|
|
@ -1,33 +1,38 @@
|
||||||
urlParams = new URLSearchParams(window.location.search);
|
var modName = "mods/spouts.js";
|
||||||
|
var runAfterAutogenMod = "mods/runAfterAutogen and onload restructure.js";
|
||||||
|
|
||||||
if(urlParams.get('spoutIncludeRandom') !== null) { //if the variable exists at all
|
if(enabledMods.includes(runAfterAutogenMod)) {
|
||||||
|
urlParams = new URLSearchParams(window.location.search);
|
||||||
|
|
||||||
|
if(urlParams.get('spoutIncludeRandom') !== null) { //if the variable exists at all
|
||||||
spoutIncludeRandom = true
|
spoutIncludeRandom = true
|
||||||
} else { //if it doesn't (and it returns null)
|
} else { //if it doesn't (and it returns null)
|
||||||
spoutIncludeRandom = false
|
spoutIncludeRandom = false
|
||||||
}
|
}
|
||||||
|
|
||||||
function _randomInt(max) {
|
function _randomInt(max) {
|
||||||
if(max >= 0) {
|
if(max >= 0) {
|
||||||
return Math.floor(Math.random() * (max + 1))
|
return Math.floor(Math.random() * (max + 1))
|
||||||
} else {
|
} else {
|
||||||
return 0 - Math.floor(Math.random() * (Math.abs(max) + 1))
|
return 0 - Math.floor(Math.random() * (Math.abs(max) + 1))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
excludedSpoutElements = ["ketchup", "liquid_cloner", "fire_cloner"]
|
excludedSpoutElements = ["ketchup", "liquid_cloner", "fire_cloner"]
|
||||||
includedSpouts = ["ketchup_spout", "spout", "udder", "torch", "sun"]
|
includedSpouts = ["ketchup_spout", "spout", "udder", "torch", "sun"]
|
||||||
|
|
||||||
runAfterLoad(function() {
|
runAfterAutogen(function() {
|
||||||
liquidArray = Object.keys(elements).filter(function(e) {
|
liquidArray = Object.keys(elements).filter(function(e) {
|
||||||
return (elements[e].state == "liquid" || elements[e].state == "gas" || elements[e].movable) && !excludedSpoutElements.includes(elements[e]);
|
return (elements[e].state == "liquid" || elements[e].state == "gas" || elements[e].movable) && !excludedSpoutElements.includes(elements[e]);
|
||||||
});
|
});
|
||||||
for(i = 0; i < liquidArray.length; i++) {
|
for(i = 0; i < liquidArray.length; i++) {
|
||||||
elements[`${liquidArray[i]}_spout`] = {
|
elements[`${liquidArray[i]}_spout`] = {
|
||||||
color: elements[liquidArray[i]].color,
|
color: elements[liquidArray[i]].color,
|
||||||
|
colorObject: elements[liquidArray[i]].colorObject,
|
||||||
behavior: [
|
behavior: [
|
||||||
`XX|CR:${liquidArray[i]}|XX`,
|
["XX",`CR:${liquidArray[i]}`,"XX"],
|
||||||
`CR:${liquidArray[i]}|XX|CR:${liquidArray[i]}`,
|
[`CR:${liquidArray[i]}`,"XX",`CR:${liquidArray[i]}`],
|
||||||
`XX|CR:${liquidArray[i]}|XX`,
|
["XX",`CR:${liquidArray[i]}`,"XX"]
|
||||||
],
|
],
|
||||||
category: "spouts",
|
category: "spouts",
|
||||||
temp: elements[liquidArray[i]].temp,
|
temp: elements[liquidArray[i]].temp,
|
||||||
|
|
@ -45,9 +50,9 @@ runAfterLoad(function() {
|
||||||
spoutChoices = spoutChoices.filter(function(e) {
|
spoutChoices = spoutChoices.filter(function(e) {
|
||||||
return !elements[e.slice(0,-6)].excludeRandom;
|
return !elements[e.slice(0,-6)].excludeRandom;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
elements.random_spout = {
|
elements.random_spout = {
|
||||||
color: ["#3e5f8a","#a334ec","#ea96f9","#a6ecf6","#70ebc8","#d9286b","#7eed91","#a18b30"],
|
color: ["#3e5f8a","#a334ec","#ea96f9","#a6ecf6","#70ebc8","#d9286b","#7eed91","#a18b30"],
|
||||||
behavior: behaviors.WALL,
|
behavior: behaviors.WALL,
|
||||||
category: "special",
|
category: "special",
|
||||||
|
|
@ -55,4 +60,9 @@ elements.random_spout = {
|
||||||
tick: function(pixel) {
|
tick: function(pixel) {
|
||||||
changePixel(pixel,spoutChoices[Math.floor(Math.random() * spoutChoices.length)])
|
changePixel(pixel,spoutChoices[Math.floor(Math.random() * spoutChoices.length)])
|
||||||
},
|
},
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
alert(`The ${runAfterAutogenMod} mod is required and has been automatically inserted (reload for this to take effect).`)
|
||||||
|
enabledMods.splice(enabledMods.indexOf(modName),0,runAfterAutogenMod)
|
||||||
|
localStorage.setItem("enabledMods", JSON.stringify(enabledMods));
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue