Merge pull request #124 from lllllllllwith10ls/main

Fixed some bugs in chem.js, mobs.js, and onTryMoveInto.js
This commit is contained in:
slweeb 2023-08-15 22:58:51 -04:00 committed by GitHub
commit e737817160
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View File

@ -411,8 +411,8 @@ if (enabledMods.includes("mods/generative_mods.js")) {
elements["hydrofluoric_acid_gas"].reactions["pyrocumulus"]= { "elem1": null, "elem2": "hydrofluoric_acid_cloud", "chance":0.4, "y":[0,12], "setting":"clouds" }; elements["hydrofluoric_acid_gas"].reactions["pyrocumulus"]= { "elem1": null, "elem2": "hydrofluoric_acid_cloud", "chance":0.4, "y":[0,12], "setting":"clouds" };
elements["hydrofluoric_acid_gas"].reactions["fire_cloud"]= { "elem1": null, "elem2": "hydrofluoric_acid_cloud", "chance":0.4, "y":[0,12], "setting":"clouds" }; elements["hydrofluoric_acid_gas"].reactions["fire_cloud"]= { "elem1": null, "elem2": "hydrofluoric_acid_cloud", "chance":0.4, "y":[0,12], "setting":"clouds" };
elements["cloud"].reactions["anesthesia"] = { elem1:"acid_cloud", elem2:null, chance:0.05 }; elements["cloud"].reactions["anesthesia"] = { elem1:"nitric_acid_cloud", elem2:null, chance:0.05 };
elements["rain_cloud"].reactions["anesthesia"] = { elem1:"acid_cloud", elem2:null, chance:0.05 }; elements["rain_cloud"].reactions["anesthesia"] = { elem1:"nitric_acid_cloud", elem2:null, chance:0.05 };
} }
function createAcid(name,reactions, gasReactions, color, category, categoryGas, tempHigh, tempLowGas, tempLow, tempHighGas, density, densityGas) function createAcid(name,reactions, gasReactions, color, category, categoryGas, tempHigh, tempLowGas, tempLow, tempHighGas, density, densityGas)
@ -462,6 +462,7 @@ function createAcid(name,reactions, gasReactions, color, category, categoryGas,
if (enabledMods.includes("mods/generative_mods.js")) { if (enabledMods.includes("mods/generative_mods.js")) {
runAfterLoad(function() { runAfterLoad(function() {
generateCloud(name); generateCloud(name);
console.log(name);
}); });
elements[name+"_gas"].reactions[name+"_gas"]= { "elem1": null, "elem2": name + "_cloud", "chance":0.3, "y":[0,12], "setting":"clouds" }; elements[name+"_gas"].reactions[name+"_gas"]= { "elem1": null, "elem2": name + "_cloud", "chance":0.3, "y":[0,12], "setting":"clouds" };
elements[name+"_gas"].reactions["rain_cloud"]= { "elem1": null, "elem2": name + "_cloud", "chance":0.4, "y":[0,12], "setting":"clouds" }; elements[name+"_gas"].reactions["rain_cloud"]= { "elem1": null, "elem2": name + "_cloud", "chance":0.4, "y":[0,12], "setting":"clouds" };
@ -2197,9 +2198,11 @@ elements.molten_iodine = {
behavior: behaviors.LIQUID, behavior: behaviors.LIQUID,
tempHigh: 184, tempHigh: 184,
tempLow: 113, tempLow: 113,
temp: 123,
stateHigh: "iodine_gas", stateHigh: "iodine_gas",
stateLow: "iodine", stateLow: "iodine",
state: "liquid", state: "liquid",
hidden: true,
}; };
elements.iodine_gas = { elements.iodine_gas = {

View File

@ -197,7 +197,7 @@ if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(explodeAtPlu
if(Array.isArray(breakIntoElement)) { if(Array.isArray(breakIntoElement)) {
breakIntoElement = breakIntoElement[Math.floor(Math.random() * breakIntoElement.length)] breakIntoElement = breakIntoElement[Math.floor(Math.random() * breakIntoElement.length)]
}; };
if(typeof(breakIntoElement) === "undefined") { if(typeof(breakIntoElement) === "undefined" || breakIntoElement === null) {
deletePixel(pixel.x,pixel.y); deletePixel(pixel.x,pixel.y);
return true; return true;
}; };

View File

@ -9,6 +9,8 @@ elements.on_try_move_into_test = {
"dirt": { elem1: "diamond" }, "dirt": { elem1: "diamond" },
}, },
state: "solid", state: "solid",
hidden: true,
excludeRandom: true,
category: "special", category: "special",
density: 1000, density: 1000,
tick: function(pixel) { tick: function(pixel) {
@ -42,12 +44,13 @@ function tryMove(pixel,nx,ny,leaveBehind,force) {
// Reactions // Reactions
newPixel = pixelMap[nx][ny]; newPixel = pixelMap[nx][ny];
var newInfo = elements[newPixel.element]; var newInfo = elements[newPixel.element];
var returnVal = false;
if(newInfo.onTryMoveInto !== undefined) { if(newInfo.onTryMoveInto !== undefined) {
newInfo.onTryMoveInto(newPixel,pixel); newInfo.onTryMoveInto(newPixel,pixel);
if(!pixel || pixel.del) { if(!pixel || pixel.del) {
return "deleted"; return "deleted";
}; };
return true; returnVal = true;
} }
var rr1 = false; var rr1 = false;
if (info.reactions !== undefined && info.reactions[newPixel.element] !== undefined) { if (info.reactions !== undefined && info.reactions[newPixel.element] !== undefined) {
@ -74,6 +77,9 @@ function tryMove(pixel,nx,ny,leaveBehind,force) {
} }
} }
} }
if(returnVal) {
return true;
}
} }
return false; return false;
} }