From 76f13837cd4fabd73f1fc4fa541a1496afe42b6d Mon Sep 17 00:00:00 2001 From: Mecoolnotcool <106288499+Mecoolnotcool@users.noreply.github.com> Date: Tue, 12 Mar 2024 16:30:39 -0500 Subject: [PATCH] Update ExtraMachines.js --- ExtraMachines.js | 230 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 227 insertions(+), 3 deletions(-) diff --git a/ExtraMachines.js b/ExtraMachines.js index ee52974e..b34bf458 100644 --- a/ExtraMachines.js +++ b/ExtraMachines.js @@ -1,10 +1,11 @@ elements.heatSensor = { color: "#ff0000", conduct: 1, - category:"machines", + category:"test", + behavior: behaviors.WALL, tick: function(pixel) { if (pixel.temp > 430 ) { - pixel.charge = 5; + pixel.charge = 1; } }, conduct: 1, @@ -90,7 +91,7 @@ elements.coal = { }; -elements.gas = { +elements.gasoline = { color: "#c9c5b1", behavior: behaviors.LIQUID, tick: function(pixel) { @@ -198,3 +199,226 @@ elements.rubber = { conduct: 0, category: "solids", }; + +elements.coolant = { + color: "#71ded3", + state: "liquid", + behavior: behaviors.LIQUID, + behavior: [ + "XX|CO:2|XX", + "CO:2|XX|CO:2", + "XX|CO:2|XX", + ], + conduct: 0.5, + category: "test", + +}; + +elements.e_cooler = { + color: elements.cooler.color, + hardness: 0.5, + state: "solid", + behavior: behaviors.WALL, + conduct: 1, + category: "machines", + behaviorOn: [ + "XX|CO:2|XX", + "CO:2|XX|CO:2", + "XX|CO:2|XX", + ], + name: "E-Cooler", +}; + +elements.e_Freezer = { + color: elements.cooler.color, + hardness: 0.5, + state: "solid", + behavior: behaviors.WALL, + conduct: 1, + category: "machines", + behaviorOn: [ + "XX|CO:10|XX", + "CO:10|XX|CO:10", + "XX|CO:10|XX", + ], + name: "E-Freezer", +}; + +elements.e_heater = { + hardness: 0.5, + state: "solid", + behavior: behaviors.WALL, + conduct: 1, + category: "machines", + color: "#881111", + behaviorOn: [ + "XX|HT:4|XX", + "HT:4|XX|HT:4", + "XX|HT:4|XX", + ], + name: "E-Heater", +}; + +elements.e_SuperHeater = { + hardness: 0.5, + state: "solid", + behavior: behaviors.WALL, + conduct: 1, + category: "machines", + color: "#881111", + behaviorOn: [ + "XX|HT:12|XX", + "HT:12|XX|HT:12", + "XX|HT:12|XX", + ], + name: "E-SuperHeater", +}; + +elements.slow_Ecloner = { + color: "#888800", + behavior: behaviors.WALL, + behaviorOn: [ + "XX|CF%10|XX", + "CF%10|XX|CF%10", + "XX|CF%10|XX", + ], + ignore: ["cloner","ecloner","clone_powder","floating_cloner","wall","ewall","turbine","solar_panel"], + category:"machines", + insulate:true, + hardness: 1, + conduct: 1, + name: "E-SlowCloner", +}; + +elements.Android = { + color: ["#a1ada5","#ebf5ee","#bac2bc","#848a86","#505251"], + category: "life", + color: ["#f3e7db","#f7ead0","#eadaba","#d7bd96","#a07e56","#825c43","#604134","#3a312a"], + category: "life", + properties: { + dead: false, + dir: 1, + panic: 0 + }, + tick: function(pixel) { + if (isEmpty(pixel.x, pixel.y+1)) { + createPixel("AndroidBody", pixel.x, pixel.y+1); + pixel.element = "AndroidHead"; + } + else if (isEmpty(pixel.x, pixel.y-1)) { + createPixel("AndroidHead", pixel.x, pixel.y-1); + pixelMap[pixel.x][pixel.y-1].color = pixel.color; + pixel.element = "AndroidBody"; + pixel.color = pixelColorPick(pixel) + } + else { + deletePixel(pixel.x, pixel.y); + } + }, + related: ["AndroidBody","AndroidHead"], + cooldown: defaultCooldown +}; + + +elements.AndroidBody = { + color: ["#a1ada5","#ebf5ee","#bac2bc","#848a86","#505251"], + category: "life", + breakInto: ["oil","metal_scrap","explosion"], + properties: { + dead: false, + dir: 1, + panic: 0 + }, + tick: function(pixel) { + if (tryMove(pixel, pixel.x, pixel.y+1)) { // Fall + if (!isEmpty(pixel.x, pixel.y-2, true)) { // Drag head down + var headpixel = pixelMap[pixel.x][pixel.y-2]; + if (headpixel.element == "AndroidHead") { + if (isEmpty(pixel.x, pixel.y-1)) { + movePixel(pixelMap[pixel.x][pixel.y-2], pixel.x, pixel.y-1); + } + else { + swapPixels(pixelMap[pixel.x][pixel.y-2], pixelMap[pixel.x][pixel.y-1]); + } + } + } + } + doHeat(pixel); + doBurning(pixel); + doElectricity(pixel); + if (pixel.dead) { + // Turn into rotten_meat if pixelTicks-dead > 500 + if (pixelTicks-pixel.dead > 200 && Math.random() < 0.1) { + changePixel(pixel,"rotten_meat"); + } + return + } + + // Find the head + if (!isEmpty(pixel.x, pixel.y-1, true) && pixelMap[pixel.x][pixel.y-1].element == "AndroidHead") { + var head = pixelMap[pixel.x][pixel.y-1]; + if (head.dead) { // If head is dead, kill body + pixel.dead = head.dead; + } + } + else { var head = null } + if (pixel.burning) { + pixel.panic += 0.1; + if (head && pixelTicks-pixel.burnStart > 240) { + pixel.color = head.color; + } + } + else if (pixel.panic > 0) { + pixel.panic -= 0.1; + } + + if (isEmpty(pixel.x, pixel.y-1)) { + // create blood if decapitated 10% chance + if (Math.random() < 0.1 && !pixel.charge) { + createPixel("oil", pixel.x, pixel.y-1); + // set dead to true 15% chance + if (Math.random() < 0.15) { + pixel.dead = pixelTicks; + } + } + } + else if (head == null) { return } + else if (Math.random() < 0.1*(isEmpty(pixel.x, pixel.y+1) ? 1 : pixel.panic+1)) { // Move 10% chance + var movesToTry = [ + [1*pixel.dir,0], + [1*pixel.dir,-1], + ]; + // While movesToTry is not empty, tryMove(pixel, x, y) with a random move, then remove it. if tryMove returns true, break. + while (movesToTry.length > 0) { + var move = movesToTry.splice(Math.floor(Math.random() * movesToTry.length), 1)[0]; + if (isEmpty(pixel.x+move[0], pixel.y+move[1]-1)) { + var origx = pixel.x+move[0]; + var origy = pixel.y+move[1]; + if (tryMove(pixel, pixel.x+move[0], pixel.y+move[1]) && pixel.x===origx && pixel.y===origy) { + movePixel(head, head.x+move[0], head.y+move[1]); + break; + } + } + } + // 15% chance to change direction + if (Math.random() < 0.15) { + pixel.dir *= -1; + } + // homeostasis + if (pixel.temp > 37) { pixel.temp -= 1; } + else if (pixel.temp < 37) { pixel.temp += 1; } + } + + } +}; + +elements.AndroidHead = { + color: ["#a1ada5","#ebf5ee","#bac2bc","#848a86","#505251"], + category: "life", + density: 1080, + state: "solid", + conduct: .05, + temp: 69, + breakInto: ["oil","metal_scrap","explosion"], +}; +