Merge pull request #617 from JustAGenericUsername/main
what do the numbers mean
This commit is contained in:
commit
84b0afd079
|
|
@ -2801,3 +2801,101 @@ elements.ray = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var specificRayStart = 0
|
||||||
|
var specificRayEnd = 20
|
||||||
|
var specificRayAngle = 0
|
||||||
|
var stopAtElement = "wall"
|
||||||
|
elements.specific_ray_emitter = {
|
||||||
|
color: "#e73e63",
|
||||||
|
behavior: behaviors.WALL,
|
||||||
|
category: "machines",
|
||||||
|
movable: false,
|
||||||
|
onSelect: function(pixel){
|
||||||
|
var rayans = prompt("Please input the desired element of this ray emitter",(rayElement||undefined));
|
||||||
|
if (!rayans) { return }
|
||||||
|
rayElement = mostSimilarElement(rayans);
|
||||||
|
var rayans2 = prompt("Should the ray be stopped by walls? Write true or false.",(rayStoppedByWalls||false));
|
||||||
|
if (rayans2 == "false"){rayStoppedByWalls = false} else {rayStoppedByWalls = true}
|
||||||
|
var rayans3 = prompt("How much should the beginning of the ray be offset from the emitter?", (specificRayStart||0));
|
||||||
|
if (!rayans3) { return }
|
||||||
|
specificRayStart = rayans3
|
||||||
|
var rayans4 = prompt("How much should the end of the ray be offset from the emitter?", (specificRayEnd||0));
|
||||||
|
if (!rayans4) { return }
|
||||||
|
specificRayEnd = rayans4
|
||||||
|
var rayans5 = prompt("What angle should the ray be emitted at? Type anything that isnt a number to use default angle logic.", (specificRayAngle||0));
|
||||||
|
if (!rayans5) { return }
|
||||||
|
specificRayAngle = rayans5
|
||||||
|
if (isNaN(parseFloat(specificRayAngle))){
|
||||||
|
specificRayAngle = "nah"
|
||||||
|
}
|
||||||
|
var rayans6 = prompt("What element should the ray stop at?", (stopAtElement||"wall"));
|
||||||
|
if (!rayans6) { return }
|
||||||
|
stopAtElement = mostSimilarElement(rayans6)
|
||||||
|
},
|
||||||
|
hoverStat: function(pixel){
|
||||||
|
return (pixel.rayElement.toUpperCase() || "unset") + ", " + (pixel.rayStoppedByWalls.toString().toUpperCase() || "unset") + ", " + (pixel.specificRayStart || "unset") + ", " + (pixel.specificRayEnd || "unset") + ", " + (pixel.specificRayAngle || "unset")
|
||||||
|
},
|
||||||
|
tick: function(pixel){
|
||||||
|
if (pixelTicks == pixel.start){
|
||||||
|
pixel.rayElement = rayElement
|
||||||
|
pixel.rayStoppedByWalls = rayStoppedByWalls
|
||||||
|
pixel.specificRayStart = specificRayStart
|
||||||
|
pixel.specificRayEnd = specificRayEnd
|
||||||
|
pixel.specificRayAngle = specificRayAngle
|
||||||
|
pixel.stopAtElement = stopAtElement
|
||||||
|
}
|
||||||
|
for (var i = 0; i < squareCoords.length; i++) {
|
||||||
|
var coord = squareCoords[i];
|
||||||
|
var x = pixel.x+coord[0];
|
||||||
|
var y = pixel.y+coord[1];
|
||||||
|
if (!isEmpty(x,y, true)){
|
||||||
|
if (pixelMap[x][y].charge && pixelMap[x][y].element == "wire"){
|
||||||
|
var dir = [0-squareCoords[i][0], 0-squareCoords[i][1]]
|
||||||
|
let startx, starty, endx, endy, magnitude
|
||||||
|
if (pixel.specificRayAngle == "nah"){
|
||||||
|
startx = pixel.x+(dir[0]*specificRayStart)
|
||||||
|
starty = pixel.y+(dir[1]*specificRayStart)
|
||||||
|
magnitude = specificRayEnd
|
||||||
|
endx = startx+(magnitude*dir[0])
|
||||||
|
endy = starty+(magnitude*dir[1])
|
||||||
|
} else {
|
||||||
|
let angleInRadians = pixel.specificRayAngle * Math.PI / 180;
|
||||||
|
console.log("Angle in radians is " + angleInRadians)
|
||||||
|
dir = [(Math.cos(angleInRadians)), (Math.sin(angleInRadians))]
|
||||||
|
startx = pixel.x+Math.round((dir[0]*specificRayStart))
|
||||||
|
starty = pixel.y+Math.round((dir[1]*specificRayStart))
|
||||||
|
magnitude = specificRayEnd
|
||||||
|
endx = startx+Math.round((magnitude*dir[0]))
|
||||||
|
endy = starty+Math.round((magnitude*dir[1]))
|
||||||
|
}
|
||||||
|
console.log("Direction seems to be " + dir)
|
||||||
|
var jcoords = lineCoords(startx, starty, endx, endy, 1)
|
||||||
|
//console.log(startx + " is the starting x, " + starty + " is the starting y, " + endx + " is the ending x, " + endy + " is the ending y. Result is " + jcoords)
|
||||||
|
for (var j = 0; j < jcoords.length; j++) {
|
||||||
|
var lcoord = jcoords[j];
|
||||||
|
var lx = lcoord[0];
|
||||||
|
var ly = lcoord[1];
|
||||||
|
// console.log(lcoord)
|
||||||
|
if (isEmpty(lx,ly)){
|
||||||
|
createPixel(pixel.rayElement, lx, ly)
|
||||||
|
pixelMap[lx][ly].temp = pixelMap[x][y].temp
|
||||||
|
if (pixel.rayElement == "ray"){
|
||||||
|
pixelMap[lx][ly].rColor = pixel.color
|
||||||
|
pixelMap[lx][ly].color = pixel.color
|
||||||
|
}
|
||||||
|
} else if (!isEmpty(lx, ly, true)){
|
||||||
|
if ((pixelMap[lx][ly].element != pixel.rayElement && pixel.rayStoppedByWalls) || pixelMap[lx][ly].element == pixel.stopAtElement){
|
||||||
|
break;
|
||||||
|
} else if (pixelMap[lx][ly].element == "ray" && pixel.rayElement == "ray"){
|
||||||
|
pixelMap[lx][ly].rColor = pixel.color
|
||||||
|
pixelMap[lx][ly].life = 10
|
||||||
|
pixelMap[lx][ly].color = pixel.color
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
insulate: true,
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue