new func for color reqs code lib
This commit is contained in:
parent
ae96b4b93c
commit
971c4cd87f
|
|
@ -1,9 +1,16 @@
|
|||
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"];
|
||||
var modName = "mods/the_ground.js";
|
||||
var libraryMod = "mods/code_library.js";
|
||||
|
||||
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"],
|
||||
["brick","wood_plank","brick"],
|
||||
|
|
@ -12,9 +19,9 @@ buildingTwoSegments = [
|
|||
["wood","wood_plank","wood_plank","wood_plank","wood"],
|
||||
["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"],
|
||||
["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"],
|
||||
|
|
@ -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"]]
|
||||
|
||||
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"],
|
||||
["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"],
|
||||
|
|
@ -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", "battery", "brick", "brick", "brick", "brick", "brick"]]
|
||||
|
||||
/*function r0to255() {
|
||||
/*function r0to255() {
|
||||
return Math.floor(Math.random() * 256);
|
||||
};*/
|
||||
};*/
|
||||
|
||||
canSupportWithEdge = function(x,y) {
|
||||
canSupportWithEdge = function(x,y) {
|
||||
if(outOfBounds(x,y)) { //count edges
|
||||
return true;
|
||||
} 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 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;
|
||||
|
|
@ -95,15 +102,66 @@ function loadPixelRowFromArray(pixelArray,centerX,centerY,evenLengthBiasedLeft=t
|
|||
}
|
||||
//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,
|
||||
elements.rad_glass.hardness = 0.25,
|
||||
delete elements.rad_glass.stateHigh;
|
||||
|
||||
//Prereq elements
|
||||
elements.crumbling_concrete = {
|
||||
elements.glass.hardness = 0.25,
|
||||
elements.rad_glass.hardness = 0.25,
|
||||
|
||||
//Prereq elements
|
||||
elements.crumbling_concrete = {
|
||||
color: "#ababab",
|
||||
tick: function(pixel) {
|
||||
var px = pixel.x;
|
||||
|
|
@ -136,9 +194,9 @@ elements.crumbling_concrete = {
|
|||
density: 2400,
|
||||
hardness: 0.5,
|
||||
breakInto: "dust",
|
||||
};
|
||||
};
|
||||
|
||||
elements.attach_powder_silk = {
|
||||
elements.attach_powder_silk = {
|
||||
color: ["#ebebeb", "#e6d9d1"],
|
||||
properties: {
|
||||
"attached": false,
|
||||
|
|
@ -169,9 +227,9 @@ elements.attach_powder_silk = {
|
|||
state: "solid",
|
||||
density: 1000,
|
||||
hidden: true
|
||||
};
|
||||
};
|
||||
|
||||
elements.glass_pane = {
|
||||
elements.glass_pane = {
|
||||
color: ["#5e807d","#679e99"],
|
||||
behavior: behaviors.SUPPORT,
|
||||
reactions: {
|
||||
|
|
@ -185,9 +243,9 @@ elements.glass_pane = {
|
|||
density: 2500,
|
||||
breakInto: "glass_shard",
|
||||
hidden: true,
|
||||
};
|
||||
};
|
||||
|
||||
elements.rad_glass_pane = {
|
||||
elements.rad_glass_pane = {
|
||||
color: ["#648c64","#6aad83"],
|
||||
behavior: [
|
||||
"XX|CR:radiation%0.075|XX",
|
||||
|
|
@ -202,11 +260,11 @@ elements.rad_glass_pane = {
|
|||
density: 2500,
|
||||
breakInto: "rad_glass_shard",
|
||||
hidden: true,
|
||||
};
|
||||
};
|
||||
|
||||
elements.wood.hardness = 0.2;
|
||||
elements.wood.hardness = 0.2;
|
||||
|
||||
elements.wood_plank = {
|
||||
elements.wood_plank = {
|
||||
color: "#ab6c3f",
|
||||
behavior: behaviors.SUPPORT,
|
||||
tempHigh: 400,
|
||||
|
|
@ -218,9 +276,9 @@ elements.wood_plank = {
|
|||
state: "solid",
|
||||
hardness: 0.2,
|
||||
breakInto: "sawdust",
|
||||
};
|
||||
};
|
||||
|
||||
elements.hanging_concrete = {
|
||||
elements.hanging_concrete = {
|
||||
color: "#ababab",
|
||||
behavior: [
|
||||
"XX|SP|XX",
|
||||
|
|
@ -235,9 +293,9 @@ elements.hanging_concrete = {
|
|||
hardness: 0.5,
|
||||
breakInto: "dust",
|
||||
hidden: true,
|
||||
};
|
||||
};
|
||||
|
||||
elements.support_copper = {
|
||||
elements.support_copper = {
|
||||
color: ["#A95232","#BE4322","#C76035"],
|
||||
behavior: behaviors.SUPPORT,
|
||||
reactions: {
|
||||
|
|
@ -254,9 +312,9 @@ elements.support_copper = {
|
|||
conduct: 0.95,
|
||||
hardness: 0.3,
|
||||
hidden: true,
|
||||
};
|
||||
};
|
||||
|
||||
elements.support_bulb = {
|
||||
elements.support_bulb = {
|
||||
color: "#a8a897",
|
||||
behavior: behaviors.SUPPORTPOWDER,
|
||||
behaviorOn: [
|
||||
|
|
@ -271,9 +329,9 @@ elements.support_bulb = {
|
|||
conduct: 1,
|
||||
breakInto: "glass_shard",
|
||||
hidden: true,
|
||||
};
|
||||
};
|
||||
|
||||
elements.support_plastic = {
|
||||
elements.support_plastic = {
|
||||
color: "#c5dede",
|
||||
behavior: behaviors.SUPPORT,
|
||||
tempHigh: 250,
|
||||
|
|
@ -285,9 +343,9 @@ elements.support_plastic = {
|
|||
state: "solid",
|
||||
density: 1052,
|
||||
hidden: true,
|
||||
};
|
||||
};
|
||||
|
||||
elements.support_steel = {
|
||||
elements.support_steel = {
|
||||
color: "#71797E",
|
||||
behavior: behaviors.SUPPORT,
|
||||
tempHigh: 1455.5,
|
||||
|
|
@ -296,27 +354,27 @@ elements.support_steel = {
|
|||
density: 7850,
|
||||
conduct: 0.42,
|
||||
hardness: 0.8,
|
||||
};
|
||||
};
|
||||
|
||||
var newAcidIgnores = ["glass_pane", "rad_glass_pane", "rad_glass_shard", "hanging_plastic"];
|
||||
for(i = 0; i < newAcidIgnores.length; i++) {
|
||||
var newAcidIgnores = ["glass_pane", "rad_glass_pane", "rad_glass_shard", "hanging_plastic"];
|
||||
for(i = 0; i < newAcidIgnores.length; i++) {
|
||||
elements.acid.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.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.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"],
|
||||
behavior: [
|
||||
"XX|CR:radiation%0.075|XX",
|
||||
|
|
@ -328,17 +386,17 @@ elements.rad_glass_shard = {
|
|||
category: "powders",
|
||||
state: "solid",
|
||||
density: 2500,
|
||||
};
|
||||
};
|
||||
|
||||
elements.molten_rad_glass = {
|
||||
elements.molten_rad_glass = {
|
||||
behavior: [
|
||||
"XX|CR:radiation%0.15 AND CR:fire%2.5|XX",
|
||||
"M2 AND CR:radiation%0.15|XX|M2 AND CR:radiation%0.15",
|
||||
"M1|M1 AND CR:radiation%0.15|M1",
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
elements.attach_concrete = {
|
||||
elements.attach_concrete = {
|
||||
color: "#ababab",
|
||||
properties: {
|
||||
"attached": false,
|
||||
|
|
@ -371,9 +429,9 @@ elements.attach_concrete = {
|
|||
density: 2400,
|
||||
hardness: 0.5,
|
||||
breakInto: "dust",
|
||||
};
|
||||
};
|
||||
|
||||
elements.steel_plate_ledge = {
|
||||
elements.steel_plate_ledge = {
|
||||
color: "#F2F2F2",
|
||||
tick: function(pixel) {
|
||||
if(pixel.attached) {
|
||||
|
|
@ -403,10 +461,10 @@ elements.steel_plate_ledge = {
|
|||
conduct: 0.32,
|
||||
hardness: 0.7,
|
||||
breakInto: "metal_scrap",
|
||||
};
|
||||
};
|
||||
|
||||
//Seeds
|
||||
elements.building_1_seed = {
|
||||
//Seeds
|
||||
elements.building_1_seed = {
|
||||
tick: function(pixel) {
|
||||
for(cx = -4; cx <= 4; cx++) {
|
||||
for(cy = -4; cy <= 4; cy++) {
|
||||
|
|
@ -463,9 +521,9 @@ elements.building_1_seed = {
|
|||
hardness: 1,
|
||||
category: "structures",
|
||||
color: ["#adadad", "#70b8ba", "#adadad", "#70b8ba", "#adadad"],
|
||||
};
|
||||
};
|
||||
|
||||
elements.building_2_seed = {
|
||||
elements.building_2_seed = {
|
||||
tick: function(pixel) {
|
||||
for(cx = -4; cx <= 4; cx++) {
|
||||
for(cy = -4; cy <= 4; cy++) {
|
||||
|
|
@ -504,9 +562,9 @@ elements.building_2_seed = {
|
|||
hardness: 1,
|
||||
category: "structures",
|
||||
color: ["#f05d43", "#f05d43", "#b06f33"],
|
||||
};
|
||||
};
|
||||
|
||||
elements.room_seed = {
|
||||
elements.room_seed = {
|
||||
color: "#ffffff",
|
||||
tick: function(pixel) {
|
||||
if(!tryMove(pixel,pixel.x,pixel.y+1)) {
|
||||
|
|
@ -522,9 +580,9 @@ elements.room_seed = {
|
|||
state: "solid",
|
||||
hardness: 1,
|
||||
category: "structures",
|
||||
};
|
||||
};
|
||||
|
||||
elements.altered_room_seed = {
|
||||
elements.altered_room_seed = {
|
||||
color: "#ffffff",
|
||||
tick: function(pixel) {
|
||||
if(!tryMove(pixel,pixel.x,pixel.y+1)) {
|
||||
|
|
@ -540,9 +598,9 @@ elements.altered_room_seed = {
|
|||
state: "solid",
|
||||
hardness: 1,
|
||||
category: "structures",
|
||||
};
|
||||
};
|
||||
|
||||
elements.altroom_compat = {
|
||||
elements.altroom_compat = {
|
||||
name: "Altered Room (Old)",
|
||||
hidden: true,
|
||||
color: "#ffffff",
|
||||
|
|
@ -595,9 +653,9 @@ elements.altroom_compat = {
|
|||
insulate: true,
|
||||
state: "solid",
|
||||
excludeRandom: true,
|
||||
},
|
||||
},
|
||||
|
||||
elements.nested_structure_test = {
|
||||
elements.nested_structure_test = {
|
||||
name: "Nested Structure Test (Old)",
|
||||
color: "#ffffff",
|
||||
cooldown: 13,
|
||||
|
|
@ -684,13 +742,14 @@ elements.nested_structure_test = {
|
|||
insulate: true,
|
||||
state: "solid",
|
||||
excludeRandom: true,
|
||||
};
|
||||
};
|
||||
|
||||
function _toggleDesertBuildings() {
|
||||
function _toggleDesertBuildings() {
|
||||
var layer = worldgentypes.desert.layers[0];
|
||||
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]);
|
||||
} else if(layer[1] === "building_1_seed") { //if the first layer is a building layer, remove it
|
||||
worldgentypes.desert.layers.shift();
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue