Added absolutely illogical code
The function return true, but despite this, the if() simply does not execute. Anyway, creeper spouts.
This commit is contained in:
parent
a4cc10f7f6
commit
ccc945c9d9
137
mods/spouts.js
137
mods/spouts.js
|
|
@ -10,6 +10,99 @@ if(enabledMods.includes(runAfterAutogenMod)) {
|
|||
spoutIncludeRandom = false
|
||||
}
|
||||
|
||||
function makeSpout(name) { //no ex post facto generation support or array spouts for this one
|
||||
if(typeof(elements[name]) !== "object") {
|
||||
throw new Error(`Nonexistent element ${name}`);
|
||||
};
|
||||
|
||||
elements[`${name}_spout`] = {
|
||||
color: elements[name].color,
|
||||
colorObject: elements[name].colorObject,
|
||||
behavior: [
|
||||
["XX",`CR:${name}`,"XX"],
|
||||
[`CR:${name}`,"XX",`CR:${name}`],
|
||||
["XX",`CR:${name}`,"XX"]
|
||||
],
|
||||
category: "spouts",
|
||||
temp: elements[name].temp,
|
||||
hardness: 1,
|
||||
};
|
||||
if(spoutIncludeRandom) {
|
||||
elements[name].excludeRandom ? elements[`${name}_spout`].excludeRandom = true : elements[`${name}_spout`].excludeRandom = false;
|
||||
} else {
|
||||
elements[`${name}_spout`].excludeRandom = true;
|
||||
};
|
||||
};
|
||||
|
||||
logString2 = "";
|
||||
|
||||
var backupCategoryWhitelist = ["land","powders","weapons","food","life","corruption","states","fey","Fantastic Creatures","dyes","energy liquids","random liquids","random gases","random rocks"];
|
||||
var backupElementWhitelist = ["mercury", "chalcopyrite_ore", "chalcopyrite_dust", "copper_concentrate", "fluxed_copper_concentrate", "unignited_pyrestone", "ignited_pyrestone", "everfire_dust", "extinguished_everfire_dust", "mistake", "polusium_oxide", "vaporized_polusium_oxide", "glowstone_dust", "redstone_dust", "soul_mud", "wet_soul_sand", "nitrogen_snow", "fusion_catalyst", "coal", "coal_coke", "blast_furnace_fuel", "molten_mythril"];
|
||||
//forces elements that logically should be spouted, but are refused even though the condition is true, to be spouted
|
||||
function spoutCondition(name) {
|
||||
if(typeof(elements[name]) !== "object") {
|
||||
throw new Error(`Nonexistent element ${name}`);
|
||||
};
|
||||
var info = elements[name];
|
||||
//console.log(`${name} (${JSON.stringify(elements[name])})`);
|
||||
if(typeof(info.state) === "undefined") {
|
||||
var state = null;
|
||||
} else {
|
||||
var state = info.state;
|
||||
};
|
||||
if(typeof(info.category) === "undefined") {
|
||||
var category = "other";
|
||||
} else {
|
||||
var category = info.category;
|
||||
};
|
||||
if(spoutBlacklist.includes(name)) {
|
||||
return false
|
||||
};
|
||||
var include = false;
|
||||
if(["liquid","gas"].includes(state)) {
|
||||
include = true;
|
||||
};
|
||||
if(info.movable) {
|
||||
include = true;
|
||||
};
|
||||
if(backupCategoryWhitelist.includes(category)) {
|
||||
include = true;
|
||||
};
|
||||
if(backupElementWhitelist.includes(name)) {
|
||||
include = true;
|
||||
};
|
||||
if(category.includes("mudstone")) {
|
||||
include = true;
|
||||
};
|
||||
//console.log(include);
|
||||
return include;
|
||||
};
|
||||
|
||||
function generateSpouts() {
|
||||
/*liquidArray = Object.keys(elements).filter(function(e) {
|
||||
return (elements[e].state == "liquid" || elements[e].state == "gas" || elements[e].movable) && !spoutBlacklist.includes(e);
|
||||
});*/
|
||||
var liquidArray = [];
|
||||
|
||||
for (key in elements) {
|
||||
if(spoutCondition(key)) {
|
||||
liquidArray.push(key);
|
||||
logString2 += `Added element ${key} to spoutee list\n`
|
||||
} else {
|
||||
logString2 += ` Did not add element ${key} to spoutee list\n`
|
||||
};
|
||||
};
|
||||
for(i = 0; i < liquidArray.length; i++) {
|
||||
makeSpout(liquidArray[i]);
|
||||
};
|
||||
spoutChoices = Object.keys(elements).filter(function(e) {
|
||||
return elements[e].category == "spouts" || includedSpouts.includes(elements[e]);
|
||||
});
|
||||
spoutChoices = spoutChoices.filter(function(e) {
|
||||
return !elements[e.slice(0,-6)].excludeRandom;
|
||||
});
|
||||
};
|
||||
|
||||
function _randomInt(max) {
|
||||
if(max >= 0) {
|
||||
return Math.floor(Math.random() * (max + 1))
|
||||
|
|
@ -18,38 +111,22 @@ if(enabledMods.includes(runAfterAutogenMod)) {
|
|||
}
|
||||
}
|
||||
|
||||
excludedSpoutElements = ["ketchup", "liquid_cloner", "fire_cloner"]
|
||||
spoutBlacklist = ["ketchup", "liquid_cloner", "fire_cloner"]
|
||||
includedSpouts = ["ketchup_spout", "spout", "udder", "torch", "sun"]
|
||||
|
||||
runAfterAutogen(function() {
|
||||
liquidArray = Object.keys(elements).filter(function(e) {
|
||||
return (elements[e].state == "liquid" || elements[e].state == "gas" || elements[e].movable) && !excludedSpoutElements.includes(elements[e]);
|
||||
});
|
||||
for(i = 0; i < liquidArray.length; i++) {
|
||||
elements[`${liquidArray[i]}_spout`] = {
|
||||
color: elements[liquidArray[i]].color,
|
||||
colorObject: elements[liquidArray[i]].colorObject,
|
||||
behavior: [
|
||||
["XX",`CR:${liquidArray[i]}`,"XX"],
|
||||
[`CR:${liquidArray[i]}`,"XX",`CR:${liquidArray[i]}`],
|
||||
["XX",`CR:${liquidArray[i]}`,"XX"]
|
||||
],
|
||||
category: "spouts",
|
||||
temp: elements[liquidArray[i]].temp,
|
||||
hardness: 1,
|
||||
};
|
||||
if(spoutIncludeRandom) {
|
||||
elements[liquidArray[i]].excludeRandom ? elements[`${liquidArray[i]}_spout`].excludeRandom = true : elements[`${liquidArray[i]}_spout`].excludeRandom = false;
|
||||
} else {
|
||||
elements[`${liquidArray[i]}_spout`].excludeRandom = true;
|
||||
};
|
||||
};
|
||||
spoutChoices = Object.keys(elements).filter(function(e) {
|
||||
return elements[e].category == "spouts" || includedSpouts.includes(elements[e]);
|
||||
});
|
||||
spoutChoices = spoutChoices.filter(function(e) {
|
||||
return !elements[e.slice(0,-6)].excludeRandom;
|
||||
});
|
||||
runAfterLoad(function() { //make sure it's the last function in the list
|
||||
runAfterAutogenList[runAfterAutogenList.length] = function() {
|
||||
for (key in elements) { //include a separate movable setter because I'm not willing to run this after final checks
|
||||
// If the element's behavior is an array and contains M1 or M2, set its movable to true
|
||||
if (elements[key].behavior && typeof elements[key].behavior[0] === "object") {
|
||||
var bstring = JSON.stringify(elements[key].behavior);
|
||||
if (bstring.indexOf("M1")!==-1 || bstring.indexOf("M2")!==-1) { elements[key].movable = true; }
|
||||
}
|
||||
if (elements[key].tick) { elements[key].movable = true; }
|
||||
}
|
||||
//Spout autogen function
|
||||
generateSpouts();
|
||||
};
|
||||
});
|
||||
|
||||
elements.random_spout = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue