new func for color reqs code lib
This commit is contained in:
parent
ae96b4b93c
commit
971c4cd87f
|
|
@ -1,3 +1,10 @@
|
||||||
|
var modName = "mods/the_ground.js";
|
||||||
|
var libraryMod = "mods/code_library.js";
|
||||||
|
|
||||||
|
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];
|
arrayLoaderVoids = ["air", "null", null];
|
||||||
buildingOneSegmentDoor = ["concrete","wood_plank","concrete","wood_plank","concrete"];
|
buildingOneSegmentDoor = ["concrete","wood_plank","concrete","wood_plank","concrete"];
|
||||||
buildingOneSegmentWindows = ["concrete","glass_pane","concrete","glass_pane","concrete"];
|
buildingOneSegmentWindows = ["concrete","glass_pane","concrete","glass_pane","concrete"];
|
||||||
|
|
@ -97,6 +104,57 @@ function loadPixelRowFromArray(pixelArray,centerX,centerY,evenLengthBiasedLeft=t
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
delete elements.rad_glass.stateHigh;
|
delete elements.rad_glass.stateHigh;
|
||||||
|
|
||||||
elements.glass.hardness = 0.25,
|
elements.glass.hardness = 0.25,
|
||||||
|
|
@ -694,3 +752,4 @@ function _toggleDesertBuildings() {
|
||||||
worldgentypes.desert.layers.shift();
|
worldgentypes.desert.layers.shift();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue