helper functions, bladesea, plasma rainbow
This commit is contained in:
parent
b0067c3e65
commit
8de3162d8c
|
|
@ -4,7 +4,7 @@ var dependencyExistence = dependencies.map(x => enabledMods.includes(x));
|
||||||
var allDependenciesExist = dependencyExistence.reduce(function(a,b) { return a && b });
|
var allDependenciesExist = dependencyExistence.reduce(function(a,b) { return a && b });
|
||||||
//console.log(allDependenciesExist);
|
//console.log(allDependenciesExist);
|
||||||
if(allDependenciesExist) {
|
if(allDependenciesExist) {
|
||||||
|
try {
|
||||||
//COMMON VARIABLES ##
|
//COMMON VARIABLES ##
|
||||||
|
|
||||||
const whiteColor = {r: 255, g: 255, b: 255};
|
const whiteColor = {r: 255, g: 255, b: 255};
|
||||||
|
|
@ -290,6 +290,26 @@ if(allDependenciesExist) {
|
||||||
return matches
|
return matches
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function elementsWith(keyQuery) {
|
||||||
|
if(typeof(window.keyQuery) == "undefined") { window.keyQuery = "" }; //necessary because of filter's idiotic no-argument policy
|
||||||
|
window.keyQuery = keyQuery;
|
||||||
|
var elemNames = Object.keys(elements);
|
||||||
|
var matches = elemNames.filter(function(name) {
|
||||||
|
return typeof(elements[name]?.[window.keyQuery]) !== "undefined"
|
||||||
|
});
|
||||||
|
return matches
|
||||||
|
};
|
||||||
|
|
||||||
|
function elementsWithout(keyInverseQuery) {
|
||||||
|
if(typeof(window.keyInverseQuery) == "undefined") { window.keyInverseQuery = "" }; //necessary because of filter's idiotic no-argument policy
|
||||||
|
window.keyInverseQuery = keyInverseQuery;
|
||||||
|
var elemNames = Object.keys(elements);
|
||||||
|
var matches = elemNames.filter(function(name) {
|
||||||
|
return typeof(elements[name]?.[window.keyInverseQuery]) === "undefined"
|
||||||
|
});
|
||||||
|
return matches
|
||||||
|
};
|
||||||
|
|
||||||
function getElementsInCategory(categoryName) {
|
function getElementsInCategory(categoryName) {
|
||||||
if(["",null,undefined].includes(categoryName)) { categoryName = "other" };
|
if(["",null,undefined].includes(categoryName)) { categoryName = "other" };
|
||||||
window.categoryQuery = categoryName;
|
window.categoryQuery = categoryName;
|
||||||
|
|
@ -4442,6 +4462,9 @@ color1 and color2 spread through striped paint like dye does with itself. <u>col
|
||||||
runAfterAutogen(function() {
|
runAfterAutogen(function() {
|
||||||
//rAA because velocity.js already puts its redef in a rAL and rAA comes after that
|
//rAA because velocity.js already puts its redef in a rAL and rAA comes after that
|
||||||
drawPixels = function(forceTick=false) {
|
drawPixels = function(forceTick=false) {
|
||||||
|
// Draw the current pixels
|
||||||
|
var canvas = document.getElementById("game");
|
||||||
|
var ctx = canvas.getContext("2d");
|
||||||
// newCurrentPixels = shuffled currentPixels
|
// newCurrentPixels = shuffled currentPixels
|
||||||
var newCurrentPixels = currentPixels.slice();
|
var newCurrentPixels = currentPixels.slice();
|
||||||
var pixelsFirst = [];
|
var pixelsFirst = [];
|
||||||
|
|
@ -4473,9 +4496,6 @@ color1 and color2 spread through striped paint like dye does with itself. <u>col
|
||||||
pixelsFirst.push(pixel);
|
pixelsFirst.push(pixel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Draw the current pixels
|
|
||||||
var canvas = document.getElementById("game");
|
|
||||||
var ctx = canvas.getContext("2d");
|
|
||||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||||
if (!settings["bg"]) {ctx.clearRect(0, 0, canvas.width, canvas.height)}
|
if (!settings["bg"]) {ctx.clearRect(0, 0, canvas.width, canvas.height)}
|
||||||
else {
|
else {
|
||||||
|
|
@ -7620,6 +7640,58 @@ color1 and color2 spread through striped paint like dye does with itself. <u>col
|
||||||
hardness: 0.7,
|
hardness: 0.7,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var temp = "firesea,lektre,concoction,mistake,unstable_mistake,toxic_mistake".split(",");
|
||||||
|
for(var i = 0; i < temp.length; i++) {
|
||||||
|
temp[i].state = "liquid";
|
||||||
|
temp[i].category = "liquids"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
elements.head.cutInto = ["bone","meat","blood"];
|
||||||
|
elements.body.cutInto = ["bone","meat","meat","blood","blood"];
|
||||||
|
elements.wood.cutInto = ["wood_plank","wood_plank","wood_plank","wood_plank","wood_plank","wood_plank","wood_plank","wood_plank","sawdust"];
|
||||||
|
elements.fish.breakInto = ["meat","meat","bone","blood"];
|
||||||
|
elements.fish.cutInto = ["meat","meat","bone","blood"];
|
||||||
|
|
||||||
|
elements.bladesea = {
|
||||||
|
color: ["#959696", "#b1b3b3", "#d4d4d4", "#bfbdbd"],
|
||||||
|
state: "liquid",
|
||||||
|
viscosity: 5,
|
||||||
|
behavior: behaviors.LIQUID,
|
||||||
|
tick: function(pixel) { //Code from R74n/vanilla "smash" tool
|
||||||
|
var pX = pixel.x;
|
||||||
|
var pY = pixel.y;
|
||||||
|
for(i = 0; i < adjacentCoords.length; i++) {
|
||||||
|
var oX = adjacentCoords[i][0];
|
||||||
|
var oY = adjacentCoords[i][1];
|
||||||
|
var fX = pX+oX;
|
||||||
|
var fY = pY+oY;
|
||||||
|
if(!isEmpty(fX,fY,true)) {
|
||||||
|
var checkPixel = pixelMap[fX][fY];
|
||||||
|
var otherElement = elements[checkPixel.element];
|
||||||
|
if (typeof(otherElement.cutInto) !== "undefined") {
|
||||||
|
var hardness = otherElement.hardness ?? 0;
|
||||||
|
if (Math.random() < (1 - hardness)) {
|
||||||
|
var cutInto = otherElement.cutInto;
|
||||||
|
// if breakInto is an array, pick one
|
||||||
|
if (Array.isArray(cutInto)) {
|
||||||
|
cutInto = randomChoice(cutInto);
|
||||||
|
};
|
||||||
|
changePixel(checkPixel,cutInto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
},
|
||||||
|
density: 200,
|
||||||
|
category: "liquids",
|
||||||
|
hidden: true,
|
||||||
|
reactions: {
|
||||||
|
"concoction": { "elem1": "bladesea", "elem2": "bladesea", "chance":0.005},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//ASSORTED RAINBOW VARIANTS ##
|
//ASSORTED RAINBOW VARIANTS ##
|
||||||
|
|
||||||
elements.concoction.reactions.diorite_gravel = {
|
elements.concoction.reactions.diorite_gravel = {
|
||||||
|
|
@ -7651,6 +7723,7 @@ color1 and color2 spread through striped paint like dye does with itself. <u>col
|
||||||
|
|
||||||
elements.rainbow.reactions ??= {};
|
elements.rainbow.reactions ??= {};
|
||||||
elements.rainbow.reactions.fire = { elem1: "fireshimmer", chance: 0.1 };
|
elements.rainbow.reactions.fire = { elem1: "fireshimmer", chance: 0.1 };
|
||||||
|
elements.rainbow.reactions.plasma = { elem1: "plasmashimmer", chance: 0.1 };
|
||||||
elements.rainbow.insulate = false;
|
elements.rainbow.insulate = false;
|
||||||
elements.rainbow.burnInto = "fireshimmer";
|
elements.rainbow.burnInto = "fireshimmer";
|
||||||
elements.rainbow.burn = 0.1;
|
elements.rainbow.burn = 0.1;
|
||||||
|
|
@ -7735,7 +7808,7 @@ color1 and color2 spread through striped paint like dye does with itself. <u>col
|
||||||
elements.rainbow.reactions.iodine = { elem1: "iodoshimmer" };
|
elements.rainbow.reactions.iodine = { elem1: "iodoshimmer" };
|
||||||
elements.rainbow.reactions.molten_iodine = { elem1: "iodoshimmer" };
|
elements.rainbow.reactions.molten_iodine = { elem1: "iodoshimmer" };
|
||||||
elements.rainbow.reactions.iodine_gas = { elem1: "iodoshimmer" };
|
elements.rainbow.reactions.iodine_gas = { elem1: "iodoshimmer" };
|
||||||
elements.astatine.tempHigh = 302;
|
runAfterLoad(function() { elements.astatine.tempHigh = 302 });
|
||||||
elements.molten_astatine ??= {}; elements.molten_astatine.tempHigh = 337;
|
elements.molten_astatine ??= {}; elements.molten_astatine.tempHigh = 337;
|
||||||
elements.rainbow.reactions.astatine = { elem1: "astatoshimmer" };
|
elements.rainbow.reactions.astatine = { elem1: "astatoshimmer" };
|
||||||
elements.rainbow.reactions.molten_astatine = { elem1: "astatoshimmer" };
|
elements.rainbow.reactions.molten_astatine = { elem1: "astatoshimmer" };
|
||||||
|
|
@ -7871,6 +7944,37 @@ color1 and color2 spread through striped paint like dye does with itself. <u>col
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
category: "special",
|
category: "special",
|
||||||
|
reactions: {
|
||||||
|
dye: elements.rainbow.reactions.dye,
|
||||||
|
plasma: {elem1: "plasmashimmer", tempMin: 10000}
|
||||||
|
},
|
||||||
|
behavior: behaviors.WALL,
|
||||||
|
state: "solid",
|
||||||
|
category: "rainbow variants",
|
||||||
|
movable: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
elements.plasmashimmer = {
|
||||||
|
color: ["#8800ff","#f2f2f2","#8800ff","#f2f2f2"],
|
||||||
|
tick: function(pixel) {
|
||||||
|
var dyeColor = pixel.dyeColor ?? null;
|
||||||
|
var t = pixelTicks*3+pixel.x+pixel.y;
|
||||||
|
var value = Math.floor(127*((Math.max(0,1-(rainbowMathlet(t,25,0)))) ** 1.1));
|
||||||
|
baseColor = "rgb(" + [Math.round(127 + (value/2)), value, 255].join(",") + ")";
|
||||||
|
if(!dyeColor) {
|
||||||
|
pixel.color = baseColor
|
||||||
|
} else {
|
||||||
|
var baseJSON = convertColorFormats(baseColor,"json");
|
||||||
|
var dyeJSON = convertColorFormats(dyeColor,"json");
|
||||||
|
var dyedColor = multiplyColors(dyeJSON,baseJSON,"json");
|
||||||
|
//70% multiplied
|
||||||
|
var semiDyedColor = averageColorObjects(dyedColor,baseJSON,0.7);
|
||||||
|
//35% dye color, 65% result
|
||||||
|
var finalColor = averageColorObjects(semiDyedColor,dyeJSON,0.65);
|
||||||
|
pixel.color = convertColorFormats(finalColor,"rgb")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
category: "special",
|
||||||
reactions: {
|
reactions: {
|
||||||
dye: elements.rainbow.reactions.dye
|
dye: elements.rainbow.reactions.dye
|
||||||
},
|
},
|
||||||
|
|
@ -7919,7 +8023,7 @@ color1 and color2 spread through striped paint like dye does with itself. <u>col
|
||||||
movable: false,
|
movable: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
elements.rainbow.behavior = behaviors.WALL;
|
elements.rainbow.behavior = behaviors.WALL; //7989 yay soshi!
|
||||||
|
|
||||||
elements.dye.ignore ??= [];
|
elements.dye.ignore ??= [];
|
||||||
|
|
||||||
|
|
@ -7986,7 +8090,7 @@ color1 and color2 spread through striped paint like dye does with itself. <u>col
|
||||||
var r = Math.floor(255*(1-Math.cos(t*Math.PI/24)));
|
var r = Math.floor(255*(1-Math.cos(t*Math.PI/24)));
|
||||||
pixel.color = "rgb("+Math.ceil((r*(7/8))+32)+","+0+","+0+")";
|
pixel.color = "rgb("+Math.ceil((r*(7/8))+32)+","+0+","+0+")";
|
||||||
},
|
},
|
||||||
behavior: behaviors.WALL, //7989 yay soshi!
|
behavior: behaviors.WALL,
|
||||||
state: "solid",
|
state: "solid",
|
||||||
category: "rainbow variants",
|
category: "rainbow variants",
|
||||||
};
|
};
|
||||||
|
|
@ -14109,7 +14213,7 @@ Pixel size (rendering only): <input id="pixelSize"> (Use if the save looks cut o
|
||||||
stain: elements.spray_paint.stain,
|
stain: elements.spray_paint.stain,
|
||||||
};
|
};
|
||||||
|
|
||||||
var temp = {
|
temp = {
|
||||||
invisible_wall: "asdfg",
|
invisible_wall: "asdfg",
|
||||||
invisible_dye: 2,
|
invisible_dye: 2,
|
||||||
invisible_dye_gas: false
|
invisible_dye_gas: false
|
||||||
|
|
@ -14769,18 +14873,10 @@ Pixel size (rendering only): <input id="pixelSize"> (Use if the save looks cut o
|
||||||
var fY = pY+oY;
|
var fY = pY+oY;
|
||||||
if(!isEmpty(fX,fY,true)) {
|
if(!isEmpty(fX,fY,true)) {
|
||||||
var checkPixel = pixelMap[fX][fY];
|
var checkPixel = pixelMap[fX][fY];
|
||||||
var thisElementName = pixel.element;
|
|
||||||
var otherElementName = checkPixel.element;
|
|
||||||
var thisElement = elements[pixel.element];
|
|
||||||
var otherElement = elements[checkPixel.element];
|
var otherElement = elements[checkPixel.element];
|
||||||
if (typeof(otherElement.breakInto) !== "undefined") {
|
if (typeof(otherElement.breakInto) !== "undefined") {
|
||||||
var hardness = null;
|
var hardness = otherElement.hardness ?? 0;
|
||||||
if (typeof(otherElement.hardness) === "number") {
|
if (Math.random() < (1 - hardness)) {
|
||||||
hardness = otherElement.hardness;
|
|
||||||
} else {
|
|
||||||
hardness = 1;
|
|
||||||
};
|
|
||||||
if (Math.random() < hardness) {
|
|
||||||
var breakInto = otherElement.breakInto;
|
var breakInto = otherElement.breakInto;
|
||||||
// if breakInto is an array, pick one
|
// if breakInto is an array, pick one
|
||||||
if (Array.isArray(breakInto)) {
|
if (Array.isArray(breakInto)) {
|
||||||
|
|
@ -19635,7 +19731,7 @@ Pixel size (rendering only): <input id="pixelSize"> (Use if the save looks cut o
|
||||||
elements.frozen_ketchup.breakInto = "ketchup_snow"
|
elements.frozen_ketchup.breakInto = "ketchup_snow"
|
||||||
elements.frozen_poisoned_ketchup.breakInto = "poisoned_ketchup_snow"
|
elements.frozen_poisoned_ketchup.breakInto = "poisoned_ketchup_snow"
|
||||||
|
|
||||||
regularShinyThingArray = ["iron", "zinc", "tin", "nickel", "silver", "aluminum", "lead", "tungsten", "brass", "bronze", "sterling", "steel", "white_gold", "blue_gold", "rose_gold", "red_gold", "solder", "gold", "pyrite", "mythril", "mithril_mythril_alloy", "titanium", "ilitium", "mithril", "beryllium", "boron", "ruthenium", "rhodium", "palladium", "rhenium", "osmium", "iridium", "platinum", "frozen_mercury", "lithium", "niobium", "ketchup_metal", "ketchup_gold", "tungstensteel", "densinium", "mithril", "signalum", "laetium"]
|
regularShinyThingArray = ["iron", "zinc", "tin", "nickel", "silver", "aluminum", "lead", "tungsten", "brass", "bronze", "sterling", "steel", "white_gold", "blue_gold", "rose_gold", "red_gold", "solder", "gold", "pyrite", "mythril", "mithril_mythril_alloy", "titanium", "ilitium", "mithril", "beryllium", "boron", "ruthenium", "rhodium", "palladium", "rhenium", "osmium", "iridium", "platinum", "frozen_mercury", "lithium", "niobium", "ketchup_metal", "ketchup_gold", "tungstensteel", "densinium", "mithril", "signalum", "laetium", "kurshunjukium", "zirconium", "jinsoulite"];
|
||||||
|
|
||||||
elements.nitrogen_snow = {
|
elements.nitrogen_snow = {
|
||||||
color: "#efefef",
|
color: "#efefef",
|
||||||
|
|
@ -19654,23 +19750,26 @@ Pixel size (rendering only): <input id="pixelSize"> (Use if the save looks cut o
|
||||||
runAfterLoad(function() {
|
runAfterLoad(function() {
|
||||||
for(i = 0; i < regularShinyThingArray.length; i++) {
|
for(i = 0; i < regularShinyThingArray.length; i++) {
|
||||||
var thing = regularShinyThingArray[i];
|
var thing = regularShinyThingArray[i];
|
||||||
if(elements[thing]) {
|
if(typeof(elements[thing]) == "object") {
|
||||||
elements[`${thing}_scrap`] = {
|
if(typeof(elements[thing]?.breakInto) == "undefined") {
|
||||||
color: elements[thing].color,
|
elements[`${thing}_scrap`] = {
|
||||||
behavior: behaviors.POWDER,
|
color: elements[thing].color,
|
||||||
tempHigh: elements[thing].tempHigh,
|
behavior: behaviors.POWDER,
|
||||||
stateHigh: thing,
|
tempHigh: elements[thing].tempHigh,
|
||||||
category: "powders",
|
stateHigh: thing,
|
||||||
hidden: true,
|
category: "powders",
|
||||||
density: elements[thing].density * 0.09,
|
hidden: true,
|
||||||
conduct: elements[thing].conduct * 0.4,
|
density: elements[thing].density * 0.09,
|
||||||
movable: true,
|
conduct: elements[thing].conduct * 0.4,
|
||||||
|
movable: true,
|
||||||
|
};
|
||||||
|
if(elements[thing].reactions) {
|
||||||
|
elements[`${thing}_scrap`].reactions = elements[thing].reactions;
|
||||||
|
};
|
||||||
|
elements[thing].breakInto = `${thing}_scrap`;
|
||||||
};
|
};
|
||||||
if(elements[thing].reactions) {
|
elements[thing].cutInto = elements[thing].breakInto
|
||||||
elements[`${thing}_scrap`].reactions = elements[thing].reactions;
|
}
|
||||||
};
|
|
||||||
elements[thing].breakInto = `${thing}_scrap`;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
elements.acid.ignore.push("densinium_scrap")
|
elements.acid.ignore.push("densinium_scrap")
|
||||||
|
|
@ -40891,6 +40990,7 @@ Make sure to save your command in a file if you want to add this preset again.`
|
||||||
state: "solid",
|
state: "solid",
|
||||||
hardness: 0.2,
|
hardness: 0.2,
|
||||||
breakInto: "sawdust",
|
breakInto: "sawdust",
|
||||||
|
cutInto: ["wood_plank","wood_plank","wood_plank","wood_plank","wood_plank","wood_plank","sawdust"]
|
||||||
};
|
};
|
||||||
|
|
||||||
elements.hanging_concrete = {
|
elements.hanging_concrete = {
|
||||||
|
|
@ -43858,7 +43958,10 @@ maxPixels (default 1000): Maximum amount of pixels/changes (if xSpacing and ySpa
|
||||||
behavior: behaviors.WALL,
|
behavior: behaviors.WALL,
|
||||||
maxColorOffset: 0
|
maxColorOffset: 0
|
||||||
};
|
};
|
||||||
|
} catch (error) {
|
||||||
|
alert(`Load failed (try reloading)\nError: ${error.stack}`);
|
||||||
|
console.error(error)
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
var nonexistentMods = dependencies.filter(function(modPath) { return !(enabledMods.includes(modPath)) });
|
var nonexistentMods = dependencies.filter(function(modPath) { return !(enabledMods.includes(modPath)) });
|
||||||
nonexistentMods.forEach(function(modPath) {
|
nonexistentMods.forEach(function(modPath) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue