new func for color reqs code lib

This commit is contained in:
Laetitia (O-01-67) 2023-03-09 15:01:52 -05:00 committed by GitHub
parent ae96b4b93c
commit 971c4cd87f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 723 additions and 664 deletions

View File

@ -1,9 +1,16 @@
arrayLoaderVoids = ["air", "null", null]; var modName = "mods/the_ground.js";
buildingOneSegmentDoor = ["concrete","wood_plank","concrete","wood_plank","concrete"]; var libraryMod = "mods/code_library.js";
buildingOneSegmentWindows = ["concrete","glass_pane","concrete","glass_pane","concrete"];
buildingOneSegmentConcrete = ["concrete","concrete","concrete","concrete","concrete"];
buildingTwoSegments = [ if(!enabledMods.includes(libraryMod)) {
enabledMods.splice(enabledMods.indexOf(modName),0,libraryMod);
alert(`The ${libraryMod} mod is required and has been automatically inserted (reload for this to take effect).`);
} else {
arrayLoaderVoids = ["air", "null", null];
buildingOneSegmentDoor = ["concrete","wood_plank","concrete","wood_plank","concrete"];
buildingOneSegmentWindows = ["concrete","glass_pane","concrete","glass_pane","concrete"];
buildingOneSegmentConcrete = ["concrete","concrete","concrete","concrete","concrete"];
buildingTwoSegments = [
["concrete","concrete","concrete","concrete","concrete"], ["concrete","concrete","concrete","concrete","concrete"],
["concrete","concrete","concrete","concrete","concrete"], ["concrete","concrete","concrete","concrete","concrete"],
["brick","wood_plank","brick"], ["brick","wood_plank","brick"],
@ -12,9 +19,9 @@ buildingTwoSegments = [
["wood","wood_plank","wood_plank","wood_plank","wood"], ["wood","wood_plank","wood_plank","wood_plank","wood"],
["wood_plank","wood_plank","wood_plank"], ["wood_plank","wood_plank","wood_plank"],
["wood_plank"] ["wood_plank"]
]; ];
oldRoom= [["brick", "brick", "brick", "brick", "brick", "brick", "brick", "glass", "glass", "glass", "glass", "glass", "brick", "brick", "brick", "brick", "brick", "brick", "brick"], oldRoom= [["brick", "brick", "brick", "brick", "brick", "brick", "brick", "glass", "glass", "glass", "glass", "glass", "brick", "brick", "brick", "brick", "brick", "brick", "brick"],
["brick", "brick", "brick", "brick", "brick", "brick", "brick", "glass", "glass", "glass", "glass", "glass", "brick", "battery","brick", "brick", "brick", "brick", "brick"], ["brick", "brick", "brick", "brick", "brick", "brick", "brick", "glass", "glass", "glass", "glass", "glass", "brick", "battery","brick", "brick", "brick", "brick", "brick"],
["glass", "glass", "air", "air", "air", "air", "air", "air", "air", "air", "air", "air", "light","light_bulb","air", "air", "air", "glass", "glass"], ["glass", "glass", "air", "air", "air", "air", "air", "air", "air", "air", "air", "air", "light","light_bulb","air", "air", "air", "glass", "glass"],
["glass", "glass", "light", "light", "air", "air", "air", "air", "air", "air", "air", "air", "air", "light", "air", "air", "air", "glass", "glass"], ["glass", "glass", "light", "light", "air", "air", "air", "air", "air", "air", "air", "air", "air", "light", "air", "air", "air", "glass", "glass"],
@ -27,7 +34,7 @@ oldRoom= [["brick", "brick", "brick", "brick", "brick", "brick", "brick",
["brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick"], ["brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick"],
["brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick"]] ["brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick"]]
altRoom= [["brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick"], altRoom= [["brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick"],
["brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "battery","brick", "brick", "brick", "brick", "brick"], ["brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "battery","brick", "brick", "brick", "brick", "brick"],
["glass", "glass", "air", "air", "air", "air", "air", "air", "air", "air", "air", "air", "light","light_bulb","air", "air", "air", "glass", "glass"], ["glass", "glass", "air", "air", "air", "air", "air", "air", "air", "air", "air", "air", "light","light_bulb","air", "air", "air", "glass", "glass"],
["glass", "glass", "light", "light", "air", "air", "air", "air", "air", "air", "air", "air", "air", "light", "air", "air", "air", "glass", "glass"], ["glass", "glass", "light", "light", "air", "air", "air", "air", "air", "air", "air", "air", "air", "light", "air", "air", "air", "glass", "glass"],
@ -40,11 +47,11 @@ altRoom= [["brick", "brick", "brick", "brick", "brick", "brick", "brick",
["brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick"], ["brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick"],
["brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "battery", "brick", "brick", "brick", "brick", "brick"]] ["brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "brick", "battery", "brick", "brick", "brick", "brick", "brick"]]
/*function r0to255() { /*function r0to255() {
return Math.floor(Math.random() * 256); return Math.floor(Math.random() * 256);
};*/ };*/
canSupportWithEdge = function(x,y) { canSupportWithEdge = function(x,y) {
if(outOfBounds(x,y)) { //count edges if(outOfBounds(x,y)) { //count edges
return true; return true;
} else { } else {
@ -56,9 +63,9 @@ canSupportWithEdge = function(x,y) {
}; };
}; };
}; };
}; };
function loadPixelRowFromArray(pixelArray,centerX,centerY,evenLengthBiasedLeft=true,doOverwrite=true) { function loadPixelRowFromArray(pixelArray,centerX,centerY,evenLengthBiasedLeft=true,doOverwrite=true) {
var arrayLength = pixelArray.length; var arrayLength = pixelArray.length;
var leftmostOffset = (evenLengthBiasedLeft ? Math.floor(0 - ((arrayLength - 1) / 2)) : Math.ceil(0 - ((arrayLength - 1) / 2))) //floor and ceil have no effect on the integer values produced by odd lengths var leftmostOffset = (evenLengthBiasedLeft ? Math.floor(0 - ((arrayLength - 1) / 2)) : Math.ceil(0 - ((arrayLength - 1) / 2))) //floor and ceil have no effect on the integer values produced by odd lengths
var forEnd = 0 - leftmostOffset; var forEnd = 0 - leftmostOffset;
@ -95,15 +102,66 @@ function loadPixelRowFromArray(pixelArray,centerX,centerY,evenLengthBiasedLeft=t
} }
//pixelMap[x][y].color = randomColor; //pixelMap[x][y].color = randomColor;
}; };
}; };
delete elements.rad_glass.stateHigh; function loadPixelRowFromArrayWithColorRowArray(pixelArray,colorArray,centerX,centerY,evenLengthBiasedLeft=true,doOverwrite=true,doColorOffset=false) {
var arrayLength = pixelArray.length;
var leftmostOffset = (evenLengthBiasedLeft ? Math.floor(0 - ((arrayLength - 1) / 2)) : Math.ceil(0 - ((arrayLength - 1) / 2))) //floor and ceil have no effect on the integer values produced by odd lengths
var forEnd = 0 - leftmostOffset;
//var randomColor = `rgb(${r0to255()},${r0to255()},${r0to255()})`;
for(i = 0; i < arrayLength; i++) {
var newElement = pixelArray[i];
var newColor = colorArray[i];
//console.log(newColor);
if(doColorOffset && !["null",null].includes(newColor)) {
newColor = convertHslObjects(normalizeColorToHslObject(newColor),"rgbjson");
var colorOffset = Math.floor(Math.random() * (Math.random() > 0.5 ? -1 : 1) * Math.random() * 15);
for(colorlet in newColor) {
newColor[colorlet] += colorOffset;
};
newColor = convertColorFormats(newColor,"rgb");
};
var x = (centerX + leftmostOffset) + i;
var y = centerY;
if(outOfBounds(x,y)) {
continue;
};
if(newElement === "null" || newElement === null) { //do nothing if element is null
continue;
};
//console.log([x,y]);
if(!isEmpty(x,y,true)) {
if(doOverwrite) {
deletePixel(x,y);
if(newElement !== "air") { //if the new element is "air", don't create a pixel after deleting
createPixel(newElement,x,y);
pixelMap[x][y].color = newColor;
};
continue;
//pixelMap[x][y].color = randomColor;
} else {;
if(newElement === "air") { //delete on "air" even if doOverwrite is false
deletePixel(x,y);
} else {
continue;
};
};
};
if(!arrayLoaderVoids.includes(newElement)) { //don't create anything if the element is a special void
createPixel(newElement,x,y);
pixelMap[x][y].color = newColor;
}
//pixelMap[x][y].color = randomColor;
};
};
elements.glass.hardness = 0.25, delete elements.rad_glass.stateHigh;
elements.rad_glass.hardness = 0.25,
//Prereq elements elements.glass.hardness = 0.25,
elements.crumbling_concrete = { elements.rad_glass.hardness = 0.25,
//Prereq elements
elements.crumbling_concrete = {
color: "#ababab", color: "#ababab",
tick: function(pixel) { tick: function(pixel) {
var px = pixel.x; var px = pixel.x;
@ -136,9 +194,9 @@ elements.crumbling_concrete = {
density: 2400, density: 2400,
hardness: 0.5, hardness: 0.5,
breakInto: "dust", breakInto: "dust",
}; };
elements.attach_powder_silk = { elements.attach_powder_silk = {
color: ["#ebebeb", "#e6d9d1"], color: ["#ebebeb", "#e6d9d1"],
properties: { properties: {
"attached": false, "attached": false,
@ -169,9 +227,9 @@ elements.attach_powder_silk = {
state: "solid", state: "solid",
density: 1000, density: 1000,
hidden: true hidden: true
}; };
elements.glass_pane = { elements.glass_pane = {
color: ["#5e807d","#679e99"], color: ["#5e807d","#679e99"],
behavior: behaviors.SUPPORT, behavior: behaviors.SUPPORT,
reactions: { reactions: {
@ -185,9 +243,9 @@ elements.glass_pane = {
density: 2500, density: 2500,
breakInto: "glass_shard", breakInto: "glass_shard",
hidden: true, hidden: true,
}; };
elements.rad_glass_pane = { elements.rad_glass_pane = {
color: ["#648c64","#6aad83"], color: ["#648c64","#6aad83"],
behavior: [ behavior: [
"XX|CR:radiation%0.075|XX", "XX|CR:radiation%0.075|XX",
@ -202,11 +260,11 @@ elements.rad_glass_pane = {
density: 2500, density: 2500,
breakInto: "rad_glass_shard", breakInto: "rad_glass_shard",
hidden: true, hidden: true,
}; };
elements.wood.hardness = 0.2; elements.wood.hardness = 0.2;
elements.wood_plank = { elements.wood_plank = {
color: "#ab6c3f", color: "#ab6c3f",
behavior: behaviors.SUPPORT, behavior: behaviors.SUPPORT,
tempHigh: 400, tempHigh: 400,
@ -218,9 +276,9 @@ elements.wood_plank = {
state: "solid", state: "solid",
hardness: 0.2, hardness: 0.2,
breakInto: "sawdust", breakInto: "sawdust",
}; };
elements.hanging_concrete = { elements.hanging_concrete = {
color: "#ababab", color: "#ababab",
behavior: [ behavior: [
"XX|SP|XX", "XX|SP|XX",
@ -235,9 +293,9 @@ elements.hanging_concrete = {
hardness: 0.5, hardness: 0.5,
breakInto: "dust", breakInto: "dust",
hidden: true, hidden: true,
}; };
elements.support_copper = { elements.support_copper = {
color: ["#A95232","#BE4322","#C76035"], color: ["#A95232","#BE4322","#C76035"],
behavior: behaviors.SUPPORT, behavior: behaviors.SUPPORT,
reactions: { reactions: {
@ -254,9 +312,9 @@ elements.support_copper = {
conduct: 0.95, conduct: 0.95,
hardness: 0.3, hardness: 0.3,
hidden: true, hidden: true,
}; };
elements.support_bulb = { elements.support_bulb = {
color: "#a8a897", color: "#a8a897",
behavior: behaviors.SUPPORTPOWDER, behavior: behaviors.SUPPORTPOWDER,
behaviorOn: [ behaviorOn: [
@ -271,9 +329,9 @@ elements.support_bulb = {
conduct: 1, conduct: 1,
breakInto: "glass_shard", breakInto: "glass_shard",
hidden: true, hidden: true,
}; };
elements.support_plastic = { elements.support_plastic = {
color: "#c5dede", color: "#c5dede",
behavior: behaviors.SUPPORT, behavior: behaviors.SUPPORT,
tempHigh: 250, tempHigh: 250,
@ -285,9 +343,9 @@ elements.support_plastic = {
state: "solid", state: "solid",
density: 1052, density: 1052,
hidden: true, hidden: true,
}; };
elements.support_steel = { elements.support_steel = {
color: "#71797E", color: "#71797E",
behavior: behaviors.SUPPORT, behavior: behaviors.SUPPORT,
tempHigh: 1455.5, tempHigh: 1455.5,
@ -296,27 +354,27 @@ elements.support_steel = {
density: 7850, density: 7850,
conduct: 0.42, conduct: 0.42,
hardness: 0.8, hardness: 0.8,
}; };
var newAcidIgnores = ["glass_pane", "rad_glass_pane", "rad_glass_shard", "hanging_plastic"]; var newAcidIgnores = ["glass_pane", "rad_glass_pane", "rad_glass_shard", "hanging_plastic"];
for(i = 0; i < newAcidIgnores.length; i++) { for(i = 0; i < newAcidIgnores.length; i++) {
elements.acid.ignore.push(newAcidIgnores[i]); elements.acid.ignore.push(newAcidIgnores[i]);
elements.acid_gas.ignore.push(newAcidIgnores[i]); elements.acid_gas.ignore.push(newAcidIgnores[i]);
}; };
elements.rad_glass.breakInto = "rad_glass_shard"; elements.rad_glass.breakInto = "rad_glass_shard";
if(!elements.glass_shard.reactions) { if(!elements.glass_shard.reactions) {
elements.glass_shard.reactions = {}; elements.glass_shard.reactions = {};
}; };
elements.glass_shard.reactions.radiation = { "elem1":"rad_glass_shard", "chance":0.33 }; elements.glass_shard.reactions.radiation = { "elem1":"rad_glass_shard", "chance":0.33 };
if(!elements.molten_glass.reactions) { if(!elements.molten_glass.reactions) {
elements.molten_glass.reactions = {}; elements.molten_glass.reactions = {};
}; };
elements.molten_glass.reactions.radiation = { "elem1":"molten_rad_glass", "chance":0.33 }; elements.molten_glass.reactions.radiation = { "elem1":"molten_rad_glass", "chance":0.33 };
elements.rad_glass_shard = { elements.rad_glass_shard = {
color: ["#648c64","#6aad83","#6a9171"], color: ["#648c64","#6aad83","#6a9171"],
behavior: [ behavior: [
"XX|CR:radiation%0.075|XX", "XX|CR:radiation%0.075|XX",
@ -328,17 +386,17 @@ elements.rad_glass_shard = {
category: "powders", category: "powders",
state: "solid", state: "solid",
density: 2500, density: 2500,
}; };
elements.molten_rad_glass = { elements.molten_rad_glass = {
behavior: [ behavior: [
"XX|CR:radiation%0.15 AND CR:fire%2.5|XX", "XX|CR:radiation%0.15 AND CR:fire%2.5|XX",
"M2 AND CR:radiation%0.15|XX|M2 AND CR:radiation%0.15", "M2 AND CR:radiation%0.15|XX|M2 AND CR:radiation%0.15",
"M1|M1 AND CR:radiation%0.15|M1", "M1|M1 AND CR:radiation%0.15|M1",
], ],
}; };
elements.attach_concrete = { elements.attach_concrete = {
color: "#ababab", color: "#ababab",
properties: { properties: {
"attached": false, "attached": false,
@ -371,9 +429,9 @@ elements.attach_concrete = {
density: 2400, density: 2400,
hardness: 0.5, hardness: 0.5,
breakInto: "dust", breakInto: "dust",
}; };
elements.steel_plate_ledge = { elements.steel_plate_ledge = {
color: "#F2F2F2", color: "#F2F2F2",
tick: function(pixel) { tick: function(pixel) {
if(pixel.attached) { if(pixel.attached) {
@ -403,10 +461,10 @@ elements.steel_plate_ledge = {
conduct: 0.32, conduct: 0.32,
hardness: 0.7, hardness: 0.7,
breakInto: "metal_scrap", breakInto: "metal_scrap",
}; };
//Seeds //Seeds
elements.building_1_seed = { elements.building_1_seed = {
tick: function(pixel) { tick: function(pixel) {
for(cx = -4; cx <= 4; cx++) { for(cx = -4; cx <= 4; cx++) {
for(cy = -4; cy <= 4; cy++) { for(cy = -4; cy <= 4; cy++) {
@ -463,9 +521,9 @@ elements.building_1_seed = {
hardness: 1, hardness: 1,
category: "structures", category: "structures",
color: ["#adadad", "#70b8ba", "#adadad", "#70b8ba", "#adadad"], color: ["#adadad", "#70b8ba", "#adadad", "#70b8ba", "#adadad"],
}; };
elements.building_2_seed = { elements.building_2_seed = {
tick: function(pixel) { tick: function(pixel) {
for(cx = -4; cx <= 4; cx++) { for(cx = -4; cx <= 4; cx++) {
for(cy = -4; cy <= 4; cy++) { for(cy = -4; cy <= 4; cy++) {
@ -504,9 +562,9 @@ elements.building_2_seed = {
hardness: 1, hardness: 1,
category: "structures", category: "structures",
color: ["#f05d43", "#f05d43", "#b06f33"], color: ["#f05d43", "#f05d43", "#b06f33"],
}; };
elements.room_seed = { elements.room_seed = {
color: "#ffffff", color: "#ffffff",
tick: function(pixel) { tick: function(pixel) {
if(!tryMove(pixel,pixel.x,pixel.y+1)) { if(!tryMove(pixel,pixel.x,pixel.y+1)) {
@ -522,9 +580,9 @@ elements.room_seed = {
state: "solid", state: "solid",
hardness: 1, hardness: 1,
category: "structures", category: "structures",
}; };
elements.altered_room_seed = { elements.altered_room_seed = {
color: "#ffffff", color: "#ffffff",
tick: function(pixel) { tick: function(pixel) {
if(!tryMove(pixel,pixel.x,pixel.y+1)) { if(!tryMove(pixel,pixel.x,pixel.y+1)) {
@ -540,9 +598,9 @@ elements.altered_room_seed = {
state: "solid", state: "solid",
hardness: 1, hardness: 1,
category: "structures", category: "structures",
}; };
elements.altroom_compat = { elements.altroom_compat = {
name: "Altered Room (Old)", name: "Altered Room (Old)",
hidden: true, hidden: true,
color: "#ffffff", color: "#ffffff",
@ -595,9 +653,9 @@ elements.altroom_compat = {
insulate: true, insulate: true,
state: "solid", state: "solid",
excludeRandom: true, excludeRandom: true,
}, },
elements.nested_structure_test = { elements.nested_structure_test = {
name: "Nested Structure Test (Old)", name: "Nested Structure Test (Old)",
color: "#ffffff", color: "#ffffff",
cooldown: 13, cooldown: 13,
@ -684,13 +742,14 @@ elements.nested_structure_test = {
insulate: true, insulate: true,
state: "solid", state: "solid",
excludeRandom: true, excludeRandom: true,
}; };
function _toggleDesertBuildings() { function _toggleDesertBuildings() {
var layer = worldgentypes.desert.layers[0]; var layer = worldgentypes.desert.layers[0];
if(layer[1] !== "building_1_seed") { //if the first layer isn't a building layer, add one if(layer[1] !== "building_1_seed") { //if the first layer isn't a building layer, add one
worldgentypes.desert.layers.unshift([0.95,"building_1_seed",0.01]); worldgentypes.desert.layers.unshift([0.95,"building_1_seed",0.01]);
} else if(layer[1] === "building_1_seed") { //if the first layer is a building layer, remove it } else if(layer[1] === "building_1_seed") { //if the first layer is a building layer, remove it
worldgentypes.desert.layers.shift(); worldgentypes.desert.layers.shift();
}; };
};
}; };