move code out
This commit is contained in:
parent
6d2d608bc7
commit
af8c1205ba
172
mods/fire_mod.js
172
mods/fire_mod.js
|
|
@ -1,4 +1,8 @@
|
||||||
/* elements.iron.reactions.radiation =
|
var modName = "mods/random_rocks.js";
|
||||||
|
var libraryMod = "mods/code_library.js";
|
||||||
|
|
||||||
|
if(enabledMods.includes(libraryMod)) {
|
||||||
|
/* elements.iron.reactions.radiation =
|
||||||
{elem1: 'dirty_water', elem2: null}
|
{elem1: 'dirty_water', elem2: null}
|
||||||
when radiation touches iron,
|
when radiation touches iron,
|
||||||
the iron turns into dirty_water (elem1)
|
the iron turns into dirty_water (elem1)
|
||||||
|
|
@ -9,15 +13,15 @@
|
||||||
when BBB touches AAA,
|
when BBB touches AAA,
|
||||||
the AAA becomes CCC
|
the AAA becomes CCC
|
||||||
and the BBB becomes DDD
|
and the BBB becomes DDD
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// imaginary reaction elements.iron.reactions.test
|
// imaginary reaction elements.iron.reactions.test
|
||||||
|
|
||||||
//Variable
|
//Variable
|
||||||
fireSpawnBlacklist = ["fire","cold_fire","rad_fire"];
|
fireSpawnBlacklist = ["fire","cold_fire","rad_fire"];
|
||||||
|
|
||||||
//doBurning
|
//doBurning
|
||||||
function doBurning(pixel) {
|
function doBurning(pixel) {
|
||||||
if (pixel.burning) { // Burning
|
if (pixel.burning) { // Burning
|
||||||
var info = elements[pixel.element];
|
var info = elements[pixel.element];
|
||||||
var burnTempChange = info.burnTempChange
|
var burnTempChange = info.burnTempChange
|
||||||
|
|
@ -117,113 +121,22 @@ function doBurning(pixel) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Use other pixels' reactions as if they were meant for the calling pixel
|
//New elements
|
||||||
function reactionStealer(pixel,newPixel,reactionTarget) {
|
|
||||||
if(!elements[reactionTarget]) {
|
|
||||||
throw new Error(`No such element ${reactionTarget}!`);
|
|
||||||
};
|
|
||||||
if(typeof(newPixel) === "undefined") { //timing issue?
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
var newElement = newPixel.element;
|
|
||||||
var newInfo = elements[newElement];
|
|
||||||
if(typeof(newInfo.reactions) === "undefined") {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
if(typeof(newInfo.reactions[reactionTarget]) === "undefined") {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
var pixel2 = pixel;
|
|
||||||
var pixel1 = newPixel;
|
|
||||||
var r = newInfo.reactions[reactionTarget];
|
|
||||||
|
|
||||||
if (r.setting && settings[r.setting]===0) {
|
elements.cold_fire.burning = true;
|
||||||
return false;
|
elements.cold_fire.burnTempChange = -1;
|
||||||
}
|
elements.cold_fire.burnTime = 25;
|
||||||
// r has the attribute "y" which is a range between two y values
|
elements.cold_fire.burnInto = "cold_smoke";
|
||||||
// r.y example: [10,30]
|
elements.cold_fire.fireElement = "cold_fire";
|
||||||
// return false if y is defined and pixel1's y is not in the range
|
elements.cold_fire.behavior = [
|
||||||
if (r.tempMin !== undefined && pixel1.temp < r.tempMin) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (r.tempMax !== undefined && pixel1.temp > r.tempMax) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (r.charged && !pixel.charge) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (r.chance !== undefined && Math.random() > r.chance) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (r.y !== undefined && (pixel1.y < r.y[0] || pixel1.y > r.y[1])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (r.elem1 !== undefined) {
|
|
||||||
// if r.elem1 is an array, set elem1 to a random element from the array, otherwise set it to r.elem1
|
|
||||||
if (Array.isArray(r.elem1)) {
|
|
||||||
var elem1 = r.elem1[Math.floor(Math.random() * r.elem1.length)];
|
|
||||||
} else { var elem1 = r.elem1; }
|
|
||||||
|
|
||||||
if (elem1 == null) {
|
|
||||||
deletePixel(pixel1.x,pixel1.y);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
changePixel(pixel1,elem1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (r.charge1) { pixel1.charge = r.charge1; }
|
|
||||||
if (r.temp1) { pixel1.temp += r.temp1; pixelTempCheck(pixel1); }
|
|
||||||
if (r.color1) { // if it's a list, use a random color from the list, else use the color1 attribute
|
|
||||||
pixel1.color = pixelColorPick(pixel1, Array.isArray(r.color1) ? r.color1[Math.floor(Math.random() * r.color1.length)] : r.color1);
|
|
||||||
}
|
|
||||||
if (r.attr1) { // add each attribute to pixel1
|
|
||||||
for (var key in r.attr1) {
|
|
||||||
pixel1[key] = r.attr1[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (r.elem2 !== undefined) {
|
|
||||||
// if r.elem2 is an array, set elem2 to a random element from the array, otherwise set it to r.elem2
|
|
||||||
if (Array.isArray(r.elem2)) {
|
|
||||||
var elem2 = r.elem2[Math.floor(Math.random() * r.elem2.length)];
|
|
||||||
} else { var elem2 = r.elem2; }
|
|
||||||
|
|
||||||
if (elem2 == null) {
|
|
||||||
deletePixel(pixel2.x,pixel2.y);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
changePixel(pixel2,elem2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (r.charge2) { pixel2.charge = r.charge2; }
|
|
||||||
if (r.temp2) { pixel2.temp += r.temp2; pixelTempCheck(pixel2); }
|
|
||||||
if (r.color2) { // if it's a list, use a random color from the list, else use the color2 attribute
|
|
||||||
pixel2.color = pixelColorPick(pixel2, Array.isArray(r.color2) ? r.color2[Math.floor(Math.random() * r.color2.length)] : r.color2);
|
|
||||||
}
|
|
||||||
if (r.attr2) { // add each attribute to pixel2
|
|
||||||
for (var key in r.attr2) {
|
|
||||||
pixel2[key] = r.attr2[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (r.func) { r.func(pixel1,pixel2); }
|
|
||||||
return r.elem1!==undefined || r.elem2!==undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
//New elements
|
|
||||||
|
|
||||||
elements.cold_fire.burning = true;
|
|
||||||
elements.cold_fire.burnTempChange = -1;
|
|
||||||
elements.cold_fire.burnTime = 25;
|
|
||||||
elements.cold_fire.burnInto = "cold_smoke";
|
|
||||||
elements.cold_fire.fireElement = "cold_fire";
|
|
||||||
elements.cold_fire.behavior = [
|
|
||||||
"M1|M1|M1",
|
"M1|M1|M1",
|
||||||
"M2|XX|M2",
|
"M2|XX|M2",
|
||||||
"XX|M2|XX"
|
"XX|M2|XX"
|
||||||
],
|
],
|
||||||
|
|
||||||
elements.cold_smoke = {
|
elements.cold_smoke = {
|
||||||
color: "#282848",
|
color: "#282848",
|
||||||
behavior: behaviors.DGAS,
|
behavior: behaviors.DGAS,
|
||||||
reactions: {
|
reactions: {
|
||||||
|
|
@ -245,9 +158,9 @@ elements.cold_smoke = {
|
||||||
state: "gas",
|
state: "gas",
|
||||||
density: 1280,
|
density: 1280,
|
||||||
stain: 0.075,
|
stain: 0.075,
|
||||||
};
|
};
|
||||||
|
|
||||||
elements.rad_fire = { //this is BBB
|
elements.rad_fire = { //this is BBB
|
||||||
color: ["#daff21","#a6ff00","#ffff00"],
|
color: ["#daff21","#a6ff00","#ffff00"],
|
||||||
behavior: [
|
behavior: [
|
||||||
"XX|CR:radiation%0.1|XX",
|
"XX|CR:radiation%0.1|XX",
|
||||||
|
|
@ -311,9 +224,9 @@ elements.rad_fire = { //this is BBB
|
||||||
state: "gas",
|
state: "gas",
|
||||||
density: 0.1,
|
density: 0.1,
|
||||||
ignoreAir: true,
|
ignoreAir: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
elements.rad_smoke = {
|
elements.rad_smoke = {
|
||||||
color: "#415c25",
|
color: "#415c25",
|
||||||
behavior: behaviors.DGAS,
|
behavior: behaviors.DGAS,
|
||||||
behavior: [
|
behavior: [
|
||||||
|
|
@ -382,9 +295,9 @@ elements.rad_smoke = {
|
||||||
state: "gas",
|
state: "gas",
|
||||||
density: 1340,
|
density: 1340,
|
||||||
stain: 0.075,
|
stain: 0.075,
|
||||||
};
|
};
|
||||||
|
|
||||||
elements.cold_torch = {
|
elements.cold_torch = {
|
||||||
"color": "#4394d6",
|
"color": "#4394d6",
|
||||||
"behavior": [
|
"behavior": [
|
||||||
"XX|CR:cold_fire|XX",
|
"XX|CR:cold_fire|XX",
|
||||||
|
|
@ -411,9 +324,9 @@ elements.cold_torch = {
|
||||||
"breakInto": "sawdust",
|
"breakInto": "sawdust",
|
||||||
"tempHigh": 600,
|
"tempHigh": 600,
|
||||||
"stateHigh": "wood",
|
"stateHigh": "wood",
|
||||||
};
|
};
|
||||||
|
|
||||||
elements.rad_torch = {
|
elements.rad_torch = {
|
||||||
"color": "#85d643",
|
"color": "#85d643",
|
||||||
"behavior": [
|
"behavior": [
|
||||||
"XX|CR:rad_fire|XX",
|
"XX|CR:rad_fire|XX",
|
||||||
|
|
@ -440,9 +353,9 @@ elements.rad_torch = {
|
||||||
"breakInto": "sawdust",
|
"breakInto": "sawdust",
|
||||||
"tempLow": -273,
|
"tempLow": -273,
|
||||||
"stateHigh": "wood",
|
"stateHigh": "wood",
|
||||||
};
|
};
|
||||||
|
|
||||||
elements.napalm = {
|
elements.napalm = {
|
||||||
color: "#e0873e",
|
color: "#e0873e",
|
||||||
behavior: [
|
behavior: [
|
||||||
"XX|SA%40 AND ST|XX",
|
"XX|SA%40 AND ST|XX",
|
||||||
|
|
@ -457,9 +370,9 @@ elements.napalm = {
|
||||||
burn: 300,
|
burn: 300,
|
||||||
burnTime: 500,
|
burnTime: 500,
|
||||||
temp: airTemp,
|
temp: airTemp,
|
||||||
},
|
},
|
||||||
|
|
||||||
elements.hypernapalm = {
|
elements.hypernapalm = {
|
||||||
name: "h y p e r n a p a l m", //HYPERNAPALM
|
name: "h y p e r n a p a l m", //HYPERNAPALM
|
||||||
color: "#bd34eb",
|
color: "#bd34eb",
|
||||||
behavior: [
|
behavior: [
|
||||||
|
|
@ -477,9 +390,9 @@ elements.hypernapalm = {
|
||||||
burnTempChange: 30,
|
burnTempChange: 30,
|
||||||
burn: 300,
|
burn: 300,
|
||||||
burnTime: 500,
|
burnTime: 500,
|
||||||
},
|
},
|
||||||
|
|
||||||
elements.cold_napalm = {
|
elements.cold_napalm = {
|
||||||
color: "#3e87e0",
|
color: "#3e87e0",
|
||||||
behavior: [
|
behavior: [
|
||||||
"XX|SA%40 AND ST|XX",
|
"XX|SA%40 AND ST|XX",
|
||||||
|
|
@ -495,9 +408,9 @@ elements.cold_napalm = {
|
||||||
fireElement: "cold_fire",
|
fireElement: "cold_fire",
|
||||||
burnTempChange: -1,
|
burnTempChange: -1,
|
||||||
burnInto: "cold_fire",
|
burnInto: "cold_fire",
|
||||||
}
|
}
|
||||||
|
|
||||||
elements.rad_napalm = {
|
elements.rad_napalm = {
|
||||||
color: "#cdf760",
|
color: "#cdf760",
|
||||||
behavior: [
|
behavior: [
|
||||||
"XX|SA%40 AND ST AND CR:radiation%1|XX",
|
"XX|SA%40 AND ST AND CR:radiation%1|XX",
|
||||||
|
|
@ -514,9 +427,9 @@ elements.rad_napalm = {
|
||||||
fireElement: "rad_fire",
|
fireElement: "rad_fire",
|
||||||
temp: airTemp,
|
temp: airTemp,
|
||||||
burnInto: "rad_fire",
|
burnInto: "rad_fire",
|
||||||
},
|
},
|
||||||
|
|
||||||
runAfterLoad(function() {
|
runAfterLoad(function() {
|
||||||
if(eLists.spout) {
|
if(eLists.spout) {
|
||||||
eLists.spout.push("cold_torch");
|
eLists.spout.push("cold_torch");
|
||||||
eLists.spout.push("rad_torch");
|
eLists.spout.push("rad_torch");
|
||||||
|
|
@ -663,4 +576,9 @@ runAfterLoad(function() {
|
||||||
elements.burning_unnamed_powder.burnTempChange = 30;
|
elements.burning_unnamed_powder.burnTempChange = 30;
|
||||||
elements.burning_unnamed_powder.fireElement = "plasma";
|
elements.burning_unnamed_powder.fireElement = "plasma";
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
alert(`The ${libraryMod} mod is required and has been automatically inserted (reload for this to take effect).`)
|
||||||
|
enabledMods.splice(enabledMods.indexOf(modName),0,libraryMod)
|
||||||
|
localStorage.setItem("enabledMods", JSON.stringify(enabledMods));
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue