diff --git a/mods/ray_cloner.js b/mods/ray_cloner.js index ea11d1ca..6d6abd8f 100644 --- a/mods/ray_cloner.js +++ b/mods/ray_cloner.js @@ -3,7 +3,7 @@ var libraryMod = "mods/code_library.js"; var propMod = "mods/prop.js"; var variablesMod = "mods/prop and prompt variables.js"; if(enabledMods.includes(libraryMod) && enabledMods.includes(propMod) && enabledMods.includes(variablesMod)) { - function placeRegularlySpacedPixels(element,startX,startY,xSpacing,ySpacing,overwrite=false,stopAt=null,spawnTemp=null,limit=1000) { + function placeRegularlySpacedPixels(element,startX,startY,xSpacing,ySpacing,overwrite=false,stopAt=null,rayIgnore=null,spawnTemp=null,limit=1000) { if(element.includes(",")) { element = element.split(",") }; var newElement = element; if(isNaN(xSpacing) || isNaN(ySpacing)) { @@ -13,15 +13,15 @@ if(enabledMods.includes(libraryMod) && enabledMods.includes(propMod) && enabledM //pixel.color = convertColorFormats("#5F5F5F","rgb"); return false; }; - if(outOfBounds(startX,startY) || (!overwrite && !isEmpty(startX,startY,false))) { + if(outOfBounds(startX,startY) /*|| (!overwrite && !isEmpty(startX,startY,false))*/) { return false; }; var posX = startX; var posY = startY; var pixelsPlaced = 0; - //console.log(stopAt); //var tries = 0; - while(!outOfBounds(posX,posY)) { + while(!outOfBounds(posX,posY) /*&& tries < 100*/) { + //tries++; if(newElement instanceof Array) { newElement = newElement[Math.floor(Math.random() * newElement.length)] }; if(!elements[newElement]) { //pixel.color = convertColorFormats("#FF5F5F","rgb"); @@ -37,12 +37,36 @@ if(enabledMods.includes(libraryMod) && enabledMods.includes(propMod) && enabledM break; } else { if(!isEmpty(posX,posY,true)) { - if(stopAt) { - var otherElement = pixelMap[posX][posY].element; - if(stopAt instanceof Array) { - if(pixel.stopAt.includes(otherElement)) { break }; + var otherElement = pixelMap[posX][posY].element; + //console.log(tries,"tries"); + //console.log("ri",rayIgnore); + if(rayIgnore) { + /*console.log( + rayIgnore instanceof Array, + otherElement, + otherElement == rayIgnore || rayIgnore.includes(otherElement) + );*/ + if(rayIgnore instanceof Array) { + if(rayIgnore.includes(otherElement)) { + posX += xSpacing; + posY += ySpacing; + //console.log(posX, posY); + continue; + }; } else { - if(otherElement == pixel.stopAt) { break }; + if(otherElement == rayIgnore) { + posX += xSpacing; + posY += ySpacing; + //console.log(posX,posY); + continue; + }; + }; + }; + if(stopAt) { + if(stopAt instanceof Array) { + if(stopAt.includes(otherElement)) { break }; + } else { + if(otherElement == stopAt) { break }; }; }; if(overwrite) { @@ -70,13 +94,34 @@ if(enabledMods.includes(libraryMod) && enabledMods.includes(propMod) && enabledM ySpacing: 0, overwrite: false, stopAt: null, + rayIgnoreSelf: true, spawnAtPixelTemp: false, maxPixels: 1000, + /*clone: "plasma", + xSpacing: 0, + ySpacing: 1, + overwrite: false, + stopAt: null, + rayIgnoreSelf: true, + spawnAtPixelTemp: true, + maxPixels: 1000,*/ }, + //temp: 100000, tick: function(pixel) { storeFirstTouchingElement(pixel,"clone",true,true); if(pixel.clone && pixel.charge) { - placeRegularlySpacedPixels(pixel.clone,pixel.x+pixel.xSpacing,pixel.y+pixel.ySpacing,pixel.xSpacing,pixel.ySpacing,pixel.overwrite,pixel.stopAt,pixel.spawnAtPixelTemp ? pixel.temp : null,pixel.maxPixels); + placeRegularlySpacedPixels( + pixel.clone, + pixel.x+pixel.xSpacing, + pixel.y+pixel.ySpacing, + pixel.xSpacing, + pixel.ySpacing, + pixel.overwrite, + pixel.stopAt, + pixel.rayIgnoreSelf ? pixel.clone : null, + pixel.spawnAtPixelTemp ? pixel.temp : null, + pixel.maxPixels + ); pixel.charge = 0 }; }, @@ -84,6 +129,7 @@ if(enabledMods.includes(libraryMod) && enabledMods.includes(propMod) && enabledM category: "machines", state: "solid", density: 3000, + insulate: true, hardness: 0.8, color: "#FFFF7F", desc: `clone: Which element to place. Cannot be an array or comma-separated string, and will be chosen from the first pixel to touch it.