From bd78eee2239897c5b9ae08e9bf4e3536187a324c Mon Sep 17 00:00:00 2001 From: IreoftheShire <155935118+IreoftheShire@users.noreply.github.com> Date: Sat, 13 Apr 2024 15:12:33 -0700 Subject: [PATCH 01/12] Update Batteries.js --- mods/Batteries.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/mods/Batteries.js b/mods/Batteries.js index 54ac3ce9..424a79a7 100644 --- a/mods/Batteries.js +++ b/mods/Batteries.js @@ -20,6 +20,11 @@ elements.low_battery= { "SH%10|CH:dead_battery%0.05|SH%10", "XX|SH%10|XX", ], + behaviorOn: [ + "XX|SH%10|XX", // shocks (adds charge) + "SH%10|CH:charged_battery%0.05|SH%10", + "XX|SH%10|XX", + ], colorOn: "#4fb613", category: "machines", tempHigh: 1455.5, @@ -30,9 +35,14 @@ elements.low_battery= { elements.dead_battery= { color: "#9c6c25", behavior: [ - "XX|SH%0.005|XX", // shocks (adds charge) - "SH%0.005|XX|SH%0.005", - "XX|SH%0.005|XX", + "XX|XX|XX", + "XX|XX|XX", + "XX|XX|XX", + ], + behaviorOn: [ + "XX|XX|XX", + "XX|CH:low_battery%0.05|XX", + "XX|XX|XX", ], colorOn: "#699e19", category: "machines", @@ -86,4 +96,4 @@ elements.radio_wave= { density: 1, //charge: 0.5, conduct: 0.01 -}; \ No newline at end of file +}; From 9a3a0c0da4a3bf48019286378876e46152b8cf49 Mon Sep 17 00:00:00 2001 From: voidapex11 <154328367+voidapex11@users.noreply.github.com> Date: Sun, 14 Apr 2024 09:48:42 +0100 Subject: [PATCH 02/12] Update pullers.js --- mods/pullers.js | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/mods/pullers.js b/mods/pullers.js index b0b4e7e7..0072128a 100644 --- a/mods/pullers.js +++ b/mods/pullers.js @@ -2,19 +2,23 @@ // a sandboxels mod that adds pullers /* ==CHANGELOG== - Version 1.1.1# + Version 1.1.2 @voidapex11 -~initial comit +~fixed spelling mistake's + + Version 1.1.1 +@voidapex11 +~initial commit +pullersDesc +imovable_inator& movable_inator +imovable wall, steel & insulation +L, R, U & D pullers +void light&dark -~don't comit without permision as you may disrupt other dev's hard work +~don't commit without permission as you may disrupt other dev's hard work ~update changelog with newer updates first ~Version format is: - rewrites.major updates.paches&minor feechers - put a '#' at end of version format if it has not been pushed to the github + rewrites.major updates.paches&minor features + put a '#' at the end of the version format if it has not been pushed to the github ~for change-log '~' means notes/changes '+' means aditions and '-' is removals */ @@ -41,10 +45,10 @@ elements.pullersDesc = { }; // for the inator reference: if you know you know -elements.imovable_inator = { +elements.immovable_inator = { color: "#525252", tool: function(pixel) { - pixel.imovable = true + pixel.immovable = true }, category: "tools", } @@ -52,14 +56,14 @@ elements.imovable_inator = { elements.movable_inator = { color: "#a8a8a8", tool: function(pixel) { - pixel.imovable = false + pixel.immovable = false }, category: 'tools', } -elements.imovable_wall = { +elements.immovable_wall = { color: "#808080", behavior: behaviors.WALL, category: "solids", @@ -67,11 +71,11 @@ elements.imovable_wall = { hardness: 1, noMix: true, properties: { - imovable: true + immovable: true } } -elements.imovable_steel = { +elements.immovable_steel = { color: "#71797e", behavior: behaviors.WALL, reactions: { @@ -92,11 +96,11 @@ elements.imovable_steel = { conduct: 0.42, hardness: 0.8, properties: { - imovable: true + immovable: true } } -elements.imovable_insulation = { +elements.immovable_insulation = { color: "#b8aea5", behavior: behaviors.WALL, category: "solids", @@ -104,7 +108,7 @@ elements.imovable_insulation = { state: "solid", noMix: true, properties: { - imovable: true + immovable: true } } @@ -123,7 +127,7 @@ elements.left_puller = { for (i = 1; i <= pixel.range; i++) { if (!isEmpty(pixel.x + i, pixel.y, true)) { - if (pixelMap[pixel.x+i][pixel.y]['imovable']) {break} + if (pixelMap[pixel.x+i][pixel.y]['immovable']) {break} else { tryMove(pixelMap[pixel.x + i][pixel.y], pixel.x + i - 1, pixel.y); } @@ -157,7 +161,7 @@ elements.right_puller = { for(h = pixel.pushStrength; h >= pixel.pushStrength; h--) { for (i = 1; i <= pixel.range; i++) { if (!isEmpty(pixel.x - i, pixel.y, true)) { - if (pixelMap[pixel.x-i][pixel.y]['imovable']) {break} + if (pixelMap[pixel.x-i][pixel.y]['immovable']) {break} else { tryMove(pixelMap[pixel.x - i][pixel.y], pixel.x - i + 1, pixel.y); } @@ -190,7 +194,7 @@ elements.down_puller = { for (i = 1; i <= pixel.range; i++) { if (!isEmpty(pixel.x, pixel.y - i, true)) { - if (pixelMap[pixel.x][pixel.y - i]['imovable']) {break} + if (pixelMap[pixel.x][pixel.y - i]['immovable]) {break} else { tryMove(pixelMap[pixel.x][pixel.y - i], pixel.x, pixel.y - i + 1); } @@ -223,7 +227,7 @@ elements.up_puller = { for (i = 1; i <= pixel.range; i++) { if (!isEmpty(pixel.x, pixel.y + i, true)) { - if (pixelMap[pixel.x][pixel.y + i]['imovable']){ + if (pixelMap[pixel.x][pixel.y + i]['immovable']){ break } else { @@ -246,5 +250,5 @@ elements.up_puller = { } if (enabledMods.includes("pushers.js")) { - console.info('compatibility with pushers.js and imovable objects coming in a later update of the pullers.js') + console.log('compatibility with pushers.js and imovable objects coming in a later update of the pullers.js\neventualy...') } From 43d858f153d8eb33edb3fc5e04be4da89d52a383 Mon Sep 17 00:00:00 2001 From: voidapex11 <154328367+voidapex11@users.noreply.github.com> Date: Sun, 14 Apr 2024 09:51:36 +0100 Subject: [PATCH 03/12] Update mod-list.html --- mod-list.html | 1 + 1 file changed, 1 insertion(+) diff --git a/mod-list.html b/mod-list.html index 0ae2d891..1cc72a2a 100644 --- a/mod-list.html +++ b/mod-list.html @@ -199,6 +199,7 @@ note_block.jsAdds musical Note BlocksAlice nousersthings.jsDestroyable machines, pipe variants, filters, and morenousernamefound portal.jsAdds portals that can teleport pixelsAlice +pushers.jsAdds pixels that pull pixels towards themvoidapex11 pushers.jsAdds pixels that push elements away from themAlice spouts.jsAdds spouts for all liquidskaeud state_voids.jsAdds several elements that each delete a specific state of matter (and combinations thereof)Alice From 2d337fa145d523306cc8e77d06bd52b912b7d584 Mon Sep 17 00:00:00 2001 From: GuyWhoGotSpringlocked <163777207+GWhoGS@users.noreply.github.com> Date: Sun, 14 Apr 2024 20:59:17 -0400 Subject: [PATCH 04/12] survival.js but it's basically cheating Credits to Ryan for the base mod (and the game itself) --- mods/easysurvival.js | 518 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 518 insertions(+) create mode 100644 mods/easysurvival.js diff --git a/mods/easysurvival.js b/mods/easysurvival.js new file mode 100644 index 00000000..9b8aba3f --- /dev/null +++ b/mods/easysurvival.js @@ -0,0 +1,518 @@ +if (!settings.survival) { + settings.survival = { + "wall": 9999, + "dirt": 9999, + "sapling": 10, + "seeds": 50, + "ice": 250, + "cloner": 10, + } +} +settings.survival.cloner = 1; +settings.unhide = 0; +// settings.survivalClone=null; settings.survival = null; saveSettings(); + +survivalTimeout = null; +function survivalSave() { + if (survivalTimeout) { clearTimeout(survivalTimeout); } + survivalTimeout = setTimeout(function(){ + saveSettings(); + },1000); +} +function survivalAdd(element,amount,skipSave) { + if (elements[element].category === "tools") { return } + if (settings.survival[element]) { + settings.survival[element] += amount; + } + else { + settings.survival[element] = amount; + } + survivalUpdate(element); + if (!skipSave) {survivalSave()} +} +function survivalRemove(element,amount,skipSave) { + if (elements[element].category === "tools") { return } + if (settings.survival[element]) { + settings.survival[element] -= amount; + survivalUpdate(element); + } + if (settings.survival[element] <= 0) { + delete settings.survival[element]; + var btn = document.getElementById("elementButton-"+element); + if (btn) { btn.remove(); } + selectElement("unknown"); + } + if (!skipSave) {survivalSave()} +} +function survivalCount(element) { + return settings.survival[element] || 0; +} +function survivalUpdate(element) { + if (element === "gold_coin") { + // if it is not an integer, round it to 0.1 + if (settings.survival.gold_coin % 1 !== 0) { + settings.survival.gold_coin = Math.round(settings.survival.gold_coin*10)/10; + } + document.getElementById("coinCount").innerHTML = settings.survival.gold_coin||0; + } + var btn = document.getElementById("elementButton-"+element); + if (elements[element] && elements[element].category === "tools") { return } + if (btn) { + btn.innerHTML = btn.innerHTML.split("(")[0]+"("+settings.survival[element]+")"; + } + else if (elements[element]) { + createElementButton(element); + document.getElementById("elementButton-"+element).innerHTML += "("+settings.survival[element]+")"; + } +} + +runAfterAutogen(function(){ + elements.erase.name = "pick_up"; + delete elements.paint.category; + delete elements.lookup.category; + delete elements.pick; + delete elements.prop; + elements.radiation.category = "tools"; + for (var element in elements) { + if (elements[element].category !== "tools") { + elements[element].hidden = true; + elements[element].category = "inventory"; + } + } + for (var element in settings.survival) { + if (!elements[element]) { continue; } + if (elements[element].category === "tools") { continue; } + createElementButton(element); + document.getElementById("elementButton-"+element).innerHTML += "("+settings.survival[element]+")"; + } +}); + +delete elements.cloner.behavior; +elements.cloner.tick = function(pixel) { + if (settings.survivalClone) { + if (Math.random() < 0.025) { + // 1 or -1 + var x = pixel.x + (Math.random() < 0.5 ? 1 : -1); + var y = pixel.y + (Math.random() < 0.5 ? 1 : -1); + if (isEmpty(x,y)) { + createPixel(settings.survivalClone,x,y); + } + } + } + else { + for (var i = 0; i < adjacentCoords.length; i++) { + var coords = adjacentCoords[i]; + var x = pixel.x + coords[0]; + var y = pixel.y + coords[1]; + if (!isEmpty(x,y,true)) { + if (pixelMap[x][y].clone) { pixel.clone = pixelMap[x][y].clone; break } + var element = pixelMap[x][y].element; + if (element === pixel.element || elements[pixel.element].ignore.indexOf(element) !== -1) { continue } + settings.survivalClone = element; + survivalSave(); + break; + } + } + } +}; +elements.cloner.ignore = elements.cloner.ignore.concat(["sun","supernova"]); +elements.cloner.desc = "You can only clone one element at a time!" + +elements.smash.tool = function(pixel) { + if (elements[pixel.element].seed === true) { return } + if (elements[pixel.element].breakInto !== undefined || (elements[pixel.element].seed !== undefined && elements[pixel.element].seed !== true)) { + // times 0.25 if not shiftDown else 1 + if (Math.random() < (elements[pixel.element].hardness || 1) * (shiftDown ? 1 : 0.25)) { + var breakInto = elements[pixel.element].breakInto; + if (elements[pixel.element].seed && (!breakInto || Math.random() < 0.5)) { + if (Math.random() < 0.2) { + breakInto = elements[pixel.element].seed; + } + else { + breakInto = null; + } + } + // if breakInto is an array, pick one + if (Array.isArray(breakInto)) { + breakInto = breakInto[Math.floor(Math.random() * breakInto.length)]; + } + if (breakInto === null) { + deletePixel(pixel.x,pixel.y); + return; + } + var oldelement = pixel.element; + changePixel(pixel,breakInto); + pixelTempCheck(pixel); + if (elements[oldelement].breakIntoColor) { + pixel.color = pixelColorPick(pixel, elements[oldelement].breakIntoColor); + } + } + } +}; + +elementWorth = { + "gold_coin": 1, + "diamond": 1000^21, + "ketchup": 150, + "jelly": 120, + "soda": 104, + "toast": 120, + "oil": 1023423, + "bread": 32, + "glass": 54, + "rad_glass": 64, + "glass_shard": 42, + "rad_shard": 312412, + "paper": 512312, + "broth": 512312, + "honey": 125, + "caramel": 53, + "sap": 34, + "candy": 325, + "popcorn": 232, + "flour": 322, + "lettuce": 2232, + "sauce": 2232, + "wood": 999, + "tree_branch": 100000, + "plant": 1, + "mushroom_cap": 1, + "mushroom_gill": 3, + "vine": 1, + "cactus": 1, + "cloner": 2, + "wall": 1000^22, + "fire": 100000^232, + "smoke": 0, + "plasma": 0, + "light": 0, + "laser": 0, + "liquid_light": 0.1, + "flash": 0, + "radiation": 0, + "petal": -1, + "cell": -1, + "cancer": -1, + "foam": -1, +} +elements.sell = { + color: ["#fff0b5","#ffe680","#c48821","#986a1a","#eca832","#f0bb62"], + tool: function(pixel) { + if (elementWorth[pixel.element] === 0) { return; } + deletePixel(pixel.x,pixel.y); + if (elementWorth[pixel.element] === -1) { return; } + survivalAdd("gold_coin",elementWorth*10[pixel.element]||1); + }, + category: "tools", + desc: "Exchanges pixels for their market value in Gold Coins x 10" +} +elements.seeds.name = "seed"; + +/* +~Cloner +~Sell +Shop + Cloner Reset + ~Ammonia + ~Dirt + ~Water + ~Seeds + ~Sapling + ~Pinecone + ~Primordial Soup + ~Worm + ~Bee + ~Human + ~TNT + Seller (Runs Sell tool on pixels that touch it) + Buyer (Cloner but uses store price every time, prompt to select item on select) +Prices tab +*/ +survivalShop = { + "dirt*25": 25, + "water*25": 250, + "ammonia*25": 500, + "seeds*1": 500, + "sapling*1": 500, + "pinecone*1": 500, + "tnt*25": 1000, + "worm*1": 1000, + "bee*1": 5000, + "primordial_soup*5": 10000, + "human*1": 50000, + "sun*1": 500000, + "milk": -200^2, +} +function survivalBuy(element) { + var price = survivalShop[element]; + if (!price) { alert("The shop isn't selling "+element+"!"); return } + if (!settings.survival.gold_coin || settings.survival.gold_coin < price) { alert("You can't afford that!"); return } + survivalRemove("gold_coin",price); + var amount = 1; + if (element.indexOf("*") !== -1) { amount = parseInt(element.split("*")[1]); element = element.split("*")[0]; } + survivalAdd(element,amount); + selectElement(element); +} +function survivalResetCloner() { + if (!settings.survival.gold_coin || settings.survival.gold_coin < 1000) { alert("You can't afford that!"); return } + survivalRemove("gold_coin",1000); + settings.survivalClone = null; + survivalSave(); +} + +worldgentypes = {} +window.addEventListener("load",function(){ + // move to start of tools + var erase = document.getElementById("elementButton-erase"); + var sell = document.getElementById("elementButton-sell"); + var parent = erase.parentElement; + parent.removeChild(sell); + parent.insertBefore(sell,parent.firstChild); + parent.removeChild(erase); + parent.insertBefore(erase,parent.firstChild); + document.getElementById("replaceButton").remove(); + document.getElementById("savesButton").remove(); + document.getElementById("elemSelectButton").remove(); + doRandomEvents = function() {} + worldGen = function() {} + worldgentypes = {} + loadSave = function() {} + showSaves = function() {} + placeImage = function() {} + chooseElementPrompt = function() {} + document.getElementById("toolControls").insertAdjacentHTML("beforeend",``); + createCategoryDiv("shop"); + var shopDiv = document.getElementById("category-shop"); + shopDiv.style.display = "none"; + shopDiv.insertAdjacentHTML("beforeend",`

You have $${settings.survival.gold_coin||0}

`); + for (var element in survivalShop) { + var price = survivalShop[element]; + var button = document.createElement("button"); + var name = element; + var amount = 1; + if (element.indexOf("*") !== -1) { amount = parseInt(element.split("*")[1]); name = element.split("*")[0]; } + var elemname = name; + name = (elements[elemname].name||name).replace(/_/g, " ").replace("."," ").replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}).replace(" ",".").replace(/ /g, ""); + button.classList.add("elementButton"); + button.setAttribute("element",element); + button.setAttribute("category","shop"); + button.setAttribute("title",amount+" "+name+" for $"+price); + button.innerHTML = name+" ("+amount+" for $"+price+")"; + if (elements[elemname]) { + if (elements[elemname].color instanceof Array) { + button.style.backgroundImage = "linear-gradient(to bottom right, "+elements[elemname].color.join(", ")+")"; + // choose the middlemost item in array + var colorObject = elements[elemname].colorObject[Math.floor(elements[elemname].colorObject.length/2)]; + if (elements[elemname].darkText !== false && (elements[elemname].darkText || (colorObject.r+colorObject.g+colorObject.b)/3 > 200)) { + button.className += " bright" + } + } + else { + button.style.background = elements[elemname].color; + var colorObject = elements[elemname].colorObject; + if (elements[elemname].darkText !== false && (elements[elemname].darkText || (colorObject.r+colorObject.g+colorObject.b)/3 > 200)) { + button.className += " bright" + } + } + } + button.addEventListener("click",function(){ + survivalBuy(this.getAttribute("element")); + }); + shopDiv.appendChild(button); + } + shopDiv.insertAdjacentHTML("beforeend",`

`); + + createCategoryDiv("prices"); + var pricesDiv = document.getElementById("category-prices"); + pricesDiv.style.display = "none"; + for (var element in elementWorth) { + if (elementWorth[element] <= 0) { continue } + var name = (elements[element].name||element).replace(/_/g, " ").replace("."," ").replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}).replace(" ","."); + // create text with the name of the element and its worth, separated by • + var text = name+"="+elementWorth[element] + " • "; + pricesDiv.insertAdjacentHTML("beforeend",`${text}`); + } + pricesDiv.innerHTML = pricesDiv.innerHTML.slice(0,-2); + pricesDiv.innerHTML = "

"+pricesDiv.innerHTML+"

"; +}); +runAfterLoad(function(){ + checkUnlock = function(element) { + return; + } + oldClearAll = clearAll; + clearAll = function() { + if (currentPixels && currentPixels.length > 0) { + for (var i = 0; i < currentPixels.length; i++) { + var pixel = currentPixels[i]; + if (pixel && pixel.element) { + survivalAdd(pixel.element,1); + } + } + } + oldClearAll(); + } + mouseAction = function(e,mouseX,mouseY,startPos) { + if (mouseType == "left") { + mouse1Action(e,mouseX,mouseY,startPos); + } + else if (mouseType == "right") { mouse2Action(e,mouseX,mouseY,startPos); } + else if (mouseType == "middle") { mouseMiddleAction(e,mouseX,mouseY); } + } + mouse1Action = function(e,mouseX=undefined,mouseY=undefined,startPos) { + if (currentElement === "erase") { mouse2Action(e,mouseX,mouseY); return; } + else if (currentElement === "pick") { mouseMiddleAction(e,mouseX,mouseY); return; } + // If x and y are undefined, get the mouse position + if (mouseX == undefined && mouseY == undefined) { + // var canvas = document.getElementById("game"); + // var ctx = canvas.getContext("2d"); + lastPos = mousePos; + mousePos = getMousePos(canvas, e); + var mouseX = mousePos.x; + var mouseY = mousePos.y; + } + var cooldowned = false; + if ((mouseSize===1 || elements[currentElement].maxSize===1) && elements[currentElement].cooldown) { + if (pixelTicks-lastPlace < elements[currentElement].cooldown) { + return; + } + cooldowned = true; + } + lastPlace = pixelTicks; + startPos = startPos || lastPos + if (!(isMobile || (cooldowned && startPos.x===lastPos.x && startPos.y===lastPos.y) || elements[currentElement].tool || elements[currentElement].category==="tools")) { + var coords = lineCoords(startPos.x,startPos.y,mouseX,mouseY); + } + else { var coords = mouseRange(mouseX,mouseY); } + var element = elements[currentElement]; + var mixList = []; + // For each x,y in coords + for (var i = 0; i < coords.length; i++) { + var x = coords[i][0]; + var y = coords[i][1]; + + if (currentElement === "mix") { + if (!isEmpty(x,y,true)) { + var pixel = pixelMap[x][y]; + if (!(elements[pixel.element].movable !== true || elements[pixel.element].noMix === true) || shiftDown) { + mixList.push(pixel); + } + } + } + else if (currentElement === "shock") { + if (!isEmpty(x,y,true)) { + // One loop that repeats 5 times if shiftDown else 1 time + for (var j = 0; j < (shiftDown ? 5 : 1); j++) { + var pixel = pixelMap[x][y]; + var con = elements[pixel.element].conduct; + if (con == undefined) {continue} + if (Math.random() < con) { // If random number is less than conductivity + if (!pixel.charge && !pixel.chargeCD) { + pixel.charge = 1; + if (elements[pixel.element].colorOn) { + pixel.color = pixelColorPick(pixel); + } + } + } + else if (elements[pixel.element].insulate != true) { // Otherwise heat the pixel (Resistance simulation) + pixel.temp += 0.25; + pixelTempCheck(pixel); + } + } + } + } + else if (elements[currentElement].tool && !(elements[currentElement].canPlace && isEmpty(x,y))) { + // run the tool function on the pixel + if (!isEmpty(x,y,true)) { + var pixel = pixelMap[x][y]; + // if the current element has an ignore property and the pixel's element is in the ignore property, don't do anything + if (elements[currentElement].ignore && elements[currentElement].ignore.indexOf(pixel.element) != -1) { + continue; + } + elements[currentElement].tool(pixel); + } + } + else if (isEmpty(x, y)) { + if (survivalCount(currentElement) < 1 && elements[currentElement].category !== "tools") { + return; + } + currentPixels.push(new Pixel(x, y, currentElement)); + if (elements[currentElement].customColor || elements[currentElement].singleColor) { + pixelMap[x][y].color = pixelColorPick(currentElement,currentColor); + } + if (elements[currentElement].category !== "tools") { survivalRemove(currentElement,1); } + } + } + if (currentElement == "mix") { + for (var i = 0; i < mixList.length; i++) { + var pixel1 = mixList[Math.floor(Math.random()*mixList.length)]; + var pixel2 = mixList[Math.floor(Math.random()*mixList.length)]; + swapPixels(pixel1,pixel2); + mixList.splice(mixList.indexOf(pixel1),1); + mixList.splice(mixList.indexOf(pixel2),1); + if (elements[pixel1.element].onMix) { + elements[pixel1.element].onMix(pixel1,pixel2); + } + if (elements[pixel2.element].onMix) { + elements[pixel2.element].onMix(pixel2,pixel1); + } + } + + } + } + mouse2Action = function(e,mouseX=undefined,mouseY=undefined,startPos) { + // Erase pixel at mouse position + if (mouseX == undefined && mouseY == undefined) { + // var canvas = document.getElementById("game"); + // var ctx = canvas.getContext("2d"); + lastPos = mousePos; + mousePos = getMousePos(canvas, e); + var mouseX = mousePos.x; + var mouseY = mousePos.y; + } + if (dragStart) { + dragStart = 0; + for (var i = 0; i < draggingPixels.length; i++) { + var pixel = draggingPixels[i]; + delete pixel.drag; + } + draggingPixels = null; + } + // If the current element is "pick" or "lookup", coords = [mouseX,mouseY] + if (currentElement == "pick" || currentElement == "lookup") { + var coords = [[mouseX,mouseY]]; + } + else if (!isMobile) { + startPos = startPos || lastPos + var coords = lineCoords(startPos.x,startPos.y,mouseX,mouseY); + } + else { + var coords = mouseRange(mouseX,mouseY); + } + // For each x,y in coords + for (var i = 0; i < coords.length; i++) { + var x = coords[i][0]; + var y = coords[i][1]; + + if (!isEmpty(x, y)) { + if (outOfBounds(x,y)) { + continue + } + var pixel = pixelMap[x][y]; + survivalAdd(pixel.element,1); + delete pixelMap[x][y]; + // Remove pixel from currentPixels + for (var j = 0; j < currentPixels.length; j++) { + if (currentPixels[j].x == x && currentPixels[j].y == y) { + currentPixels.splice(j, 1); + break; + } + } + } + } + } +}) + +window.addEventListener("beforeunload",function(){ + clearAll(); + saveSettings(); +}); \ No newline at end of file From cdfcc8a612d9493e2b8d91da539e27494de02592 Mon Sep 17 00:00:00 2001 From: GuyWhoGotSpringlocked <163777207+GWhoGS@users.noreply.github.com> Date: Sun, 14 Apr 2024 21:10:05 -0400 Subject: [PATCH 05/12] survival.js but cheating credits to Ryan for making the game & the mod survival.js --- easysurvival.js | 917 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 917 insertions(+) create mode 100644 easysurvival.js diff --git a/easysurvival.js b/easysurvival.js new file mode 100644 index 00000000..86fdcc7b --- /dev/null +++ b/easysurvival.js @@ -0,0 +1,917 @@ +behaviors = { + POWDER_OLD: [ + "XX|XX|XX", + "XX|XX|XX", + "M2|M1|M2", + ], + POWDER: function(pixel) { + if (pixel.start === pixelTicks) {return} + if (pixel.charge && elements[pixel.element].behaviorOn) { + pixelTick(pixel) + } + if (!tryMove(pixel, pixel.x, pixel.y+1)) { + if (Math.random() < 0.5) { + if (!tryMove(pixel, pixel.x+1, pixel.y+1)) { + tryMove(pixel, pixel.x-1, pixel.y+1); + } + } else { + if (!tryMove(pixel, pixel.x-1, pixel.y+1)) { + tryMove(pixel, pixel.x+1, pixel.y+1); + } + } + } + doDefaults(pixel); + }, + AGPOWDER: [ + "M2|M1|M2", + "XX|XX|XX", + "XX|XX|XX", + ], + LIQUID_OLD: [ + "XX|XX|XX", + "M2|XX|M2", + "M1|M1|M1", + ], + LIQUID: function(pixel) { + if (pixel.start === pixelTicks) {return} + if (pixel.charge && elements[pixel.element].behaviorOn) { + pixelTick(pixel) + } + if (elements[pixel.element].viscosity && (!((Math.random()*100) < 100 / Math.pow(elements[pixel.element].viscosity, 0.25)))) { + var move1Spots = [ + [pixel.x, pixel.y+1] + ] + } + else { + var move1Spots = [ + [pixel.x+1, pixel.y+1], + [pixel.x, pixel.y+1], + [pixel.x-1, pixel.y+1], + ] + } + var moved = false; + for (var i = 0; i < move1Spots.length; i++) { + var coords = move1Spots[Math.floor(Math.random()*move1Spots.length)]; + if (tryMove(pixel, coords[0], coords[1])) { moved = true; break; } + else { move1Spots.splice(move1Spots.indexOf(coords), 1); } + } + if (!moved) { + if (elements[pixel.element].viscosity===undefined || !(!((Math.random()*100) < 100 / Math.pow(elements[pixel.element].viscosity, 0.25)))) { + if (Math.random() < 0.5) { + if (!tryMove(pixel, pixel.x+1, pixel.y)) { + tryMove(pixel, pixel.x-1, pixel.y); + } + } else { + if (!tryMove(pixel, pixel.x-1, pixel.y)) { + tryMove(pixel, pixel.x+1, pixel.y); + } + } + } + } + doDefaults(pixel); + }, + SUPERFLUID_OLD: [ + "XX|XX|XX", + "XX|XX|M2 AND BO", + "XX|M1|M2", + ], + SUPERFLUID: function(pixel) { + if (pixel.start === pixelTicks) {return} + if (pixel.charge && elements[pixel.element].behaviorOn) { + pixelTick(pixel) + } + if (!tryMove(pixel, pixel.x, pixel.y+1)) { + // go either left or right depending on pixel.flipX + var newx = pixel.flipX ? pixel.x-1 : pixel.x+1; + if (Math.random() < 0.5) { + if (!tryMove(pixel, newx, pixel.y)) { + pixel.flipX = !pixel.flipX; + tryMove(pixel, newx, pixel.y+1); + } + } + else { + if (!tryMove(pixel, newx, pixel.y+1)) { + if (!tryMove(pixel, newx, pixel.y)) { pixel.flipX = !pixel.flipX; } + } + } + } + doDefaults(pixel); + }, + LIGHTWEIGHT: [ + "XX|XX|XX", + "XX|FX%0.25|XX", + "M2%10|M1%10|M1%10", + ], + SLIDE: [ + "XX|XX|XX", + "XX|XX|M2 AND BO", + "XX|M1|M1", + ], + AGLIQUID: [ + "M1|M1|M1", + "M2|XX|M2", + "XX|XX|XX", + ], + WALL: [ + "XX|XX|XX", + "XX|XX|XX", + "XX|XX|XX", + ], + UL_UR: [ + "M1|M1|M1", + "M2|XX|M2", + "XX|M2|XX", + ], + UL_UR_OPTIMIZED: function(pixel) { + if (pixel.start === pixelTicks) {return} + if (pixel.charge && elements[pixel.element].behaviorOn) { + pixelTick(pixel) + } + var move1Spots = [ + [pixel.x, pixel.y-1], + [pixel.x+1, pixel.y-1], + [pixel.x-1, pixel.y-1], + ] + var moved = false; + for (var i = 0; i < move1Spots.length; i++) { + var coords = move1Spots[Math.floor(Math.random()*move1Spots.length)]; + if (tryMove(pixel, coords[0], coords[1])) { moved = true; break; } + else { move1Spots.splice(move1Spots.indexOf(coords), 1);} + } + if (!moved && !pixel.del) { + var move2Spots = [ + [pixel.x, pixel.y+1], + [pixel.x+1, pixel.y], + [pixel.x-1, pixel.y], + ] + for (var i = 0; i < move2Spots.length; i++) { + var coords = move2Spots[Math.floor(Math.random()*move2Spots.length)]; + if (tryMove(pixel, coords[0], coords[1])) { break; } + else { move2Spots.splice(move2Spots.indexOf(coords), 1); } + } + } + if (!pixel.del) { doDefaults(pixel); } + }, + GAS_OLD: [ + "M2|M1|M2", + "M1|XX|M1", + "M2|M1|M2", + ], + GAS: function(pixel) { + if (pixel.start === pixelTicks) {return} + if (pixel.charge && elements[pixel.element].behaviorOn) { + pixelTick(pixel) + } + var move1Spots = [ + [pixel.x, pixel.y+1], + [pixel.x, pixel.y-1], + [pixel.x+1, pixel.y], + [pixel.x-1, pixel.y], + ] + var moved = false; + for (var i = 0; i < move1Spots.length; i++) { + var coords = move1Spots[Math.floor(Math.random()*move1Spots.length)]; + if (tryMove(pixel, coords[0], coords[1])) { moved = true; break; } + else { move1Spots.splice(move1Spots.indexOf(coords), 1);} + } + if (!moved) { + var move2Spots = [ + [pixel.x+1, pixel.y+1], + [pixel.x-1, pixel.y+1], + [pixel.x+1, pixel.y-1], + [pixel.x-1, pixel.y-1], + ] + for (var i = 0; i < move2Spots.length; i++) { + var coords = move2Spots[Math.floor(Math.random()*move2Spots.length)]; + if (tryMove(pixel, coords[0], coords[1])) { break; } + else { move2Spots.splice(move2Spots.indexOf(coords), 1); } + } + } + doDefaults(pixel); + }, + DGAS: [ + "M2|M1|M2", + "M1|DL%5|M1", + "M2|M1|M2", + ], + SUPPORT: [ + "XX|XX|XX", + "SP|XX|SP", + "XX|M1|XX", + ], + SUPPORTPOWDER: [ + "XX|XX|XX", + "SP|XX|SP", + "M2|M1|M2", + ], + DELETE: [ + "XX|DL|XX", + "DL|XX|DL", + "XX|DL|XX", + ], + FILL: [ + "XX|CL|XX", + "CL|XX|CL", + "XX|CL|XX", + ], + CLONER: [ + "XX|CF|XX", + "CF|XX|CF", + "XX|CF|XX", + ], + SUPERCLONER: [ + "CF|CF|CF", + "CF|CF|CF", + "CF|CF|CF", + ], + STURDYPOWDER: [ + "XX|XX|XX", + "XX|XX|XX", + "XX|M1|XX", + ], + SELFDELETE: [ + "XX|XX|XX", + "XX|DL|XX", + "XX|XX|XX", + ], + FOAM: [ + "XX|XX|XX", + "XX|DL%5|XX", + "M2%25|M1%25|M2%25", + ], + BUBBLE: [ + "XX|XX|XX", + "XX|DL%0.25 AND FX%1|M1%5", + "XX|M1%1|M1%2", + ], + STICKY: [ + "XX|ST|XX", + "ST|XX|ST", + "XX|ST AND M1|XX", + ], + MOLTEN: [ + "XX|CR:fire%2.5|XX", + "M2|XX|M2", + "M1|M1|M1", + ], + RADPOWDER: [ + "XX|CR:radiation%1|XX", + "CR:radiation%1|XX|CR:radiation%1", + "M2|M1|M2", + ], + RADMOLTEN: [ + "XX|CR:fire,fire,fire,radiation%4.5|XX", + "M2 AND CR:radiation%1|XX|M2 AND CR:radiation%1", + "M1|M1|M1", + ], + RADLIQUID: [ + "XX|CR:radiation%2|XX", + "M2 AND CR:radiation%2|XX|M2 AND CR:radiation%2", + "M1|M1|M1", + ], + BOUNCY: function(pixel) { + if (pixel.bx===undefined) { + // choose 1, 0, or -1 + pixel.bx = Math.random() < 0.5 ? 1 : Math.random() < 0.5 ? 0 : -1; + pixel.by = Math.random() < 0.5 ? 1 : Math.random() < 0.5 ? 0 : -1; + // if both are 0, make one of them 1 or -1 + if (pixel.bx===0 && pixel.by===0) { + if (Math.random() < 0.5) { pixel.bx = Math.random() < 0.5 ? 1 : -1; } + else { pixel.by = Math.random() < 0.5 ? 1 : -1; } + } + } + // move and invert direction if hit + if (!pixel.del && pixel.bx && !tryMove(pixel, pixel.x+pixel.bx, pixel.y)) { pixel.bx = -pixel.bx; } + if (!pixel.del && pixel.by && !tryMove(pixel, pixel.x, pixel.y+pixel.by)) { pixel.by = -pixel.by; } + }, + FEEDPIXEL: function(pixel) { + if (!pixel.food) { pixel.food = 1 } + else { pixel.food ++ } + if (pixel.food > (elements[pixel.element].foodNeed||30)) { + // loop through adjacentCoords and check each pixel to lay an egg + for (var i = 0; i < adjacentCoords.length; i++) { + var x = pixel.x+adjacentCoords[i][0]; + var y = pixel.y+adjacentCoords[i][1]; + if (isEmpty(x, y)) { + if (elements[pixel.element].egg) { + createPixel(elements[pixel.element].egg,x,y) + } + else { + createPixel("egg",x,y) + pixelMap[x][y].animal = elements[pixel.element].baby || pixel.element; + if (elements[pixel.element].eggColor) { + pixelMap[x][y].color = pixelColorPick(pixelMap[x][y],elements[pixel.element].eggColor) + } + } + pixel.food = 0; + break; + } + } + } + }, + KILLPIXEL1: function(pixel) { + pixel.dead = true; + }, + KILLPIXEL2: function(pixel1,pixel2) { + pixel2.dead = true; + }, + FLY: function(pixel, onHit) { + var nx = pixel.flipX ? -1 : 1; + var ny = Math.random() < 0.5 ? -1 : 1; + var hit = false; + if (!tryMove(pixel, pixel.x+nx, pixel.y+ny)) { + if (!tryMove(pixel, pixel.x+nx, pixel.y-ny)) { + if (!tryMove(pixel, pixel.x, pixel.y+ny)) { + if (!tryMove(pixel, pixel.x, pixel.y-ny)) {hit=[pixel.x, pixel.y-ny]} + }else {hit=[pixel.x, pixel.y+ny]} + }else {hit=[pixel.x+nx, pixel.y-ny]} + }else {hit=[pixel.x+nx, pixel.y+ny]} + if (hit && onHit) { + if (!isEmpty(hit[0], hit[1], true)) { + onHit(pixel, pixelMap[hit[0]][hit[1]]); + } + else {onHit(pixel);} + } + if (pixel.del) {return} + if (!isEmpty(pixel.x+nx,pixel.y) || Math.random() < 0.02) { + pixel.flipX = !pixel.flipX; + } + if (pixel.charge && elements[pixel.element].behaviorOn) { + pixelTick(pixel) + } + doDefaults(pixel); + }, + CRAWLER: function(pixel) { + if (Math.random() < 0.08) { // flip + pixel.flipX = !pixel.flipX; + } + var dir = pixel.flipX ? -1 : 1; + var dirY = pixel.flipY ? -1 : 1; + if (!tryMove(pixel,pixel.x,pixel.y+dirY)) { // fall or climb + if (!tryMove(pixel,pixel.x+dir,pixel.y)) { // hits wall + if (!pixel.hilled && !isEmpty(pixel.x+dir,pixel.y,true) && pixelMap[pixel.x+dir][pixel.y].element === "ant_wall") { + pixel.hilled = true; + } + tryMove(pixel,pixel.x+dir,pixel.y + (Math.random() < 0.25 ? 1 : -1)); + } + if (Math.random() < 0.01 && !isEmpty(pixel.x+dir,pixel.y+1,true) && eLists.CRAWLTHRU.indexOf(pixelMap[pixel.x+dir][pixel.y+1].element) !== -1) { + if (!pixel.hilled || !isEmpty(pixel.x+dir,pixel.y,true) && pixelMap[pixel.x+dir][pixel.y].element === "ant_wall") { + var wallCoords = [ + [-1,-1],[1,-1], + [-1,0],[1,0], + [0,1] + ]; + if (!isEmpty(pixel.x,pixel.y-2)) { + wallCoords.push([0,-1]) + } + if (Math.random() < 0.15) { wallCoords.push([-1,1]) } + if (Math.random() < 0.15) { wallCoords.push([1,1]) } + // loop through wallCoords, change pixel to ant_wall if in crawlthru + for (var i = 0; i < wallCoords.length; i++) { + var x = pixel.x+dir+wallCoords[i][0]; + var y = pixel.y+1+wallCoords[i][1]; + if (!isEmpty(x,y,true) && eLists.CRAWLTHRU.indexOf(pixelMap[x][y].element) !== -1) { + changePixel(pixelMap[x][y],"ant_wall"); + } + } + deletePixel(pixel.x+dir,pixel.y+1); + tryMove(pixel,pixel.x+dir,pixel.y+1); + } + } + else if (Math.random() < 0.08 && !isEmpty(pixel.x+dir,pixel.y-1,true) && eLists.CRAWLTHRU.indexOf(pixelMap[pixel.x+dir][pixel.y-1].element) !== -1) { + swapPixels(pixel,pixelMap[pixel.x+dir][pixel.y-1]); + } + } + doDefaults(pixel); + } +} + +elements.supercloner = { + color: "#dddd00", + behavior: behaviors.SUPERCLONER, + ignore: ["ecloner","slow_cloner","clone_powder","floating_cloner","wall","ewall", "cloner"], + category:"inventory", + insulate:true, + hardness: 1, + darkText: true, +} + +if (!settings.survival) { + settings.survival = { + "wall": 9999, + "dirt": 9999, + "sapling": 10, + "seeds": 50, + "ice": 250, + "cloner": 10, + "supercloner": 10 + } +} +settings.survival.cloner = 1; +settings.unhide = 0; +// settings.survivalClone=null; settings.survival = null; saveSettings(); + +survivalTimeout = null; +function survivalSave() { + if (survivalTimeout) { clearTimeout(survivalTimeout); } + survivalTimeout = setTimeout(function(){ + saveSettings(); + },1000); +} +function survivalAdd(element,amount,skipSave) { + if (elements[element].category === "tools") { return } + if (settings.survival[element]) { + settings.survival[element] += amount; + } + else { + settings.survival[element] = amount; + } + survivalUpdate(element); + if (!skipSave) {survivalSave()} +} +function survivalRemove(element,amount,skipSave) { + if (elements[element].category === "tools") { return } + if (settings.survival[element]) { + settings.survival[element] -= amount; + survivalUpdate(element); + } + if (settings.survival[element] <= 0) { + delete settings.survival[element]; + var btn = document.getElementById("elementButton-"+element); + if (btn) { btn.remove(); } + selectElement("unknown"); + } + if (!skipSave) {survivalSave()} +} +function survivalCount(element) { + return settings.survival[element] || 0; +} +function survivalUpdate(element) { + if (element === "gold_coin") { + // if it is not an integer, round it to 0.1 + if (settings.survival.gold_coin % 1 !== 0) { + settings.survival.gold_coin = Math.round(settings.survival.gold_coin*10)/10; + } + document.getElementById("coinCount").innerHTML = settings.survival.gold_coin||0; + } + var btn = document.getElementById("elementButton-"+element); + if (elements[element] && elements[element].category === "tools") { return } + if (btn) { + btn.innerHTML = btn.innerHTML.split("(")[0]+"("+settings.survival[element]+")"; + } + else if (elements[element]) { + createElementButton(element); + document.getElementById("elementButton-"+element).innerHTML += "("+settings.survival[element]+")"; + } +} + +runAfterAutogen(function(){ + elements.erase.name = "pick_up"; + delete elements.paint.category; + delete elements.lookup.category; + delete elements.pick; + delete elements.prop; + elements.radiation.category = "tools"; + for (var element in elements) { + if (elements[element].category !== "tools") { + elements[element].hidden = true; + elements[element].category = "inventory"; + } + } + for (var element in settings.survival) { + if (!elements[element]) { continue; } + if (elements[element].category === "tools") { continue; } + createElementButton(element); + document.getElementById("elementButton-"+element).innerHTML += "("+settings.survival[element]+")"; + } +}); + +delete elements.cloner.behavior; +elements.cloner.tick = function(pixel) { + if (settings.survivalClone) { + if (Math.random() < 0.025) { + // 1 or -1 + var x = pixel.x + (Math.random() < 0.5 ? 1 : -1); + var y = pixel.y + (Math.random() < 0.5 ? 1 : -1); + if (isEmpty(x,y)) { + createPixel(settings.survivalClone,x,y); + } + } + } + else { + for (var i = 0; i < adjacentCoords.length; i++) { + var coords = adjacentCoords[i]; + var x = pixel.x + coords[0]; + var y = pixel.y + coords[1]; + if (!isEmpty(x,y,true)) { + if (pixelMap[x][y].clone) { pixel.clone = pixelMap[x][y].clone; break } + var element = pixelMap[x][y].element; + if (element === pixel.element || elements[pixel.element].ignore.indexOf(element) !== -1) { continue } + settings.survivalClone = element; + survivalSave(); + break; + } + } + } +}; +elements.cloner.ignore = elements.cloner.ignore.concat(["sun","supernova"]); +elements.cloner.desc = "You can only clone one element at a time!" + +elements.smash.tool = function(pixel) { + if (elements[pixel.element].seed === true) { return } + if (elements[pixel.element].breakInto !== undefined || (elements[pixel.element].seed !== undefined && elements[pixel.element].seed !== true)) { + // times 0.25 if not shiftDown else 1 + if (Math.random() < (elements[pixel.element].hardness || 1) * (shiftDown ? 1 : 0.25)) { + var breakInto = elements[pixel.element].breakInto; + if (elements[pixel.element].seed && (!breakInto || Math.random() < 0.5)) { + if (Math.random() < 0.2) { + breakInto = elements[pixel.element].seed; + } + else { + breakInto = null; + } + } + // if breakInto is an array, pick one + if (Array.isArray(breakInto)) { + breakInto = breakInto[Math.floor(Math.random() * breakInto.length)]; + } + if (breakInto === null) { + deletePixel(pixel.x,pixel.y); + return; + } + var oldelement = pixel.element; + changePixel(pixel,breakInto); + pixelTempCheck(pixel); + if (elements[oldelement].breakIntoColor) { + pixel.color = pixelColorPick(pixel, elements[oldelement].breakIntoColor); + } + } + } +}; + +elementWorth = { + "gold_coin": 1, + "diamond": 1000^21, + "ketchup": 150, + "jelly": 120, + "soda": 104, + "toast": 120, + "oil": 1023423, + "bread": 32, + "glass": 54, + "rad_glass": 64, + "glass_shard": 42, + "rad_shard": 312412, + "paper": 512312, + "broth": 512312, + "honey": 125, + "caramel": 53, + "sap": 34, + "candy": 325, + "popcorn": 232, + "flour": 322, + "lettuce": 2232, + "sauce": 2232, + "wood": 999, + "tree_branch": 100000, + "plant": 1, + "mushroom_cap": 1, + "mushroom_gill": 3, + "vine": 1, + "cactus": 1, + "cloner": 2, + "wall": 1000^22, + "fire": 100000^232, + "smoke": 0, + "plasma": 0, + "light": 0, + "laser": 0, + "liquid_light": 0.1, + "flash": 0, + "radiation": 0, + "petal": -1, + "cell": -1, + "cancer": -1, + "foam": -1, +} +elements.sell = { + color: ["#fff0b5","#ffe680","#c48821","#986a1a","#eca832","#f0bb62"], + tool: function(pixel) { + if (elementWorth[pixel.element] === 0) { return; } + deletePixel(pixel.x,pixel.y); + if (elementWorth[pixel.element] === -1) { return; } + survivalAdd("gold_coin",elementWorth*10[pixel.element]||1); + }, + category: "tools", + desc: "Exchanges pixels for their market value in Gold Coins x 10" +} +elements.seeds.name = "seed"; + +/* +~Cloner +~Sell +Shop + Cloner Reset + ~Ammonia + ~Dirt + ~Water + ~Seeds + ~Sapling + ~Pinecone + ~Primordial Soup + ~Worm + ~Bee + ~Human + ~TNT + Seller (Runs Sell tool on pixels that touch it) + Buyer (Cloner but uses store price every time, prompt to select item on select) +Prices tab +*/ +survivalShop = { + "dirt*25": 25, + "water*25": 250, + "ammonia*25": 500, + "seeds*1": 500, + "sapling*1": 500, + "pinecone*1": 500, + "tnt*25": 1000, + "worm*1": 1000, + "bee*1": 5000, + "primordial_soup*5": 10000, + "human*1": 50000, + "sun*1": 500000, + "milk": -200^2, +} +function survivalBuy(element) { + var price = survivalShop[element]; + if (!price) { alert("The shop isn't selling "+element+"!"); return } + if (!settings.survival.gold_coin || settings.survival.gold_coin < price) { alert("You can't afford that!"); return } + survivalRemove("gold_coin",price); + var amount = 1; + if (element.indexOf("*") !== -1) { amount = parseInt(element.split("*")[1]); element = element.split("*")[0]; } + survivalAdd(element,amount); + selectElement(element); +} +function survivalResetCloner() { + if (!settings.survival.gold_coin || settings.survival.gold_coin < 1000) { alert("You can't afford that!"); return } + survivalRemove("gold_coin",1000); + settings.survivalClone = null; + survivalSave(); +} + +worldgentypes = {} +window.addEventListener("load",function(){ + // move to start of tools + var erase = document.getElementById("elementButton-erase"); + var sell = document.getElementById("elementButton-sell"); + var parent = erase.parentElement; + parent.removeChild(sell); + parent.insertBefore(sell,parent.firstChild); + parent.removeChild(erase); + parent.insertBefore(erase,parent.firstChild); + document.getElementById("replaceButton").remove(); + document.getElementById("savesButton").remove(); + document.getElementById("elemSelectButton").remove(); + doRandomEvents = function() {} + worldGen = function() {} + worldgentypes = {} + loadSave = function() {} + showSaves = function() {} + placeImage = function() {} + chooseElementPrompt = function() {} + document.getElementById("toolControls").insertAdjacentHTML("beforeend",``); + createCategoryDiv("shop"); + var shopDiv = document.getElementById("category-shop"); + shopDiv.style.display = "none"; + shopDiv.insertAdjacentHTML("beforeend",`

You have $${settings.survival.gold_coin||0}

`); + for (var element in survivalShop) { + var price = survivalShop[element]; + var button = document.createElement("button"); + var name = element; + var amount = 1; + if (element.indexOf("*") !== -1) { amount = parseInt(element.split("*")[1]); name = element.split("*")[0]; } + var elemname = name; + name = (elements[elemname].name||name).replace(/_/g, " ").replace("."," ").replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}).replace(" ",".").replace(/ /g, ""); + button.classList.add("elementButton"); + button.setAttribute("element",element); + button.setAttribute("category","shop"); + button.setAttribute("title",amount+" "+name+" for $"+price); + button.innerHTML = name+" ("+amount+" for $"+price+")"; + if (elements[elemname]) { + if (elements[elemname].color instanceof Array) { + button.style.backgroundImage = "linear-gradient(to bottom right, "+elements[elemname].color.join(", ")+")"; + // choose the middlemost item in array + var colorObject = elements[elemname].colorObject[Math.floor(elements[elemname].colorObject.length/2)]; + if (elements[elemname].darkText !== false && (elements[elemname].darkText || (colorObject.r+colorObject.g+colorObject.b)/3 > 200)) { + button.className += " bright" + } + } + else { + button.style.background = elements[elemname].color; + var colorObject = elements[elemname].colorObject; + if (elements[elemname].darkText !== false && (elements[elemname].darkText || (colorObject.r+colorObject.g+colorObject.b)/3 > 200)) { + button.className += " bright" + } + } + } + button.addEventListener("click",function(){ + survivalBuy(this.getAttribute("element")); + }); + shopDiv.appendChild(button); + } + shopDiv.insertAdjacentHTML("beforeend",`

`); + + createCategoryDiv("prices"); + var pricesDiv = document.getElementById("category-prices"); + pricesDiv.style.display = "none"; + for (var element in elementWorth) { + if (elementWorth[element] <= 0) { continue } + var name = (elements[element].name||element).replace(/_/g, " ").replace("."," ").replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}).replace(" ","."); + // create text with the name of the element and its worth, separated by • + var text = name+"="+elementWorth[element] + " • "; + pricesDiv.insertAdjacentHTML("beforeend",`${text}`); + } + pricesDiv.innerHTML = pricesDiv.innerHTML.slice(0,-2); + pricesDiv.innerHTML = "

"+pricesDiv.innerHTML+"

"; +}); +runAfterLoad(function(){ + checkUnlock = function(element) { + return; + } + oldClearAll = clearAll; + clearAll = function() { + if (currentPixels && currentPixels.length > 0) { + for (var i = 0; i < currentPixels.length; i++) { + var pixel = currentPixels[i]; + if (pixel && pixel.element) { + survivalAdd(pixel.element,1); + } + } + } + oldClearAll(); + } + mouseAction = function(e,mouseX,mouseY,startPos) { + if (mouseType == "left") { + mouse1Action(e,mouseX,mouseY,startPos); + } + else if (mouseType == "right") { mouse2Action(e,mouseX,mouseY,startPos); } + else if (mouseType == "middle") { mouseMiddleAction(e,mouseX,mouseY); } + } + mouse1Action = function(e,mouseX=undefined,mouseY=undefined,startPos) { + if (currentElement === "erase") { mouse2Action(e,mouseX,mouseY); return; } + else if (currentElement === "pick") { mouseMiddleAction(e,mouseX,mouseY); return; } + // If x and y are undefined, get the mouse position + if (mouseX == undefined && mouseY == undefined) { + // var canvas = document.getElementById("game"); + // var ctx = canvas.getContext("2d"); + lastPos = mousePos; + mousePos = getMousePos(canvas, e); + var mouseX = mousePos.x; + var mouseY = mousePos.y; + } + var cooldowned = false; + if ((mouseSize===1 || elements[currentElement].maxSize===1) && elements[currentElement].cooldown) { + if (pixelTicks-lastPlace < elements[currentElement].cooldown) { + return; + } + cooldowned = true; + } + lastPlace = pixelTicks; + startPos = startPos || lastPos + if (!(isMobile || (cooldowned && startPos.x===lastPos.x && startPos.y===lastPos.y) || elements[currentElement].tool || elements[currentElement].category==="tools")) { + var coords = lineCoords(startPos.x,startPos.y,mouseX,mouseY); + } + else { var coords = mouseRange(mouseX,mouseY); } + var element = elements[currentElement]; + var mixList = []; + // For each x,y in coords + for (var i = 0; i < coords.length; i++) { + var x = coords[i][0]; + var y = coords[i][1]; + + if (currentElement === "mix") { + if (!isEmpty(x,y,true)) { + var pixel = pixelMap[x][y]; + if (!(elements[pixel.element].movable !== true || elements[pixel.element].noMix === true) || shiftDown) { + mixList.push(pixel); + } + } + } + else if (currentElement === "shock") { + if (!isEmpty(x,y,true)) { + // One loop that repeats 5 times if shiftDown else 1 time + for (var j = 0; j < (shiftDown ? 5 : 1); j++) { + var pixel = pixelMap[x][y]; + var con = elements[pixel.element].conduct; + if (con == undefined) {continue} + if (Math.random() < con) { // If random number is less than conductivity + if (!pixel.charge && !pixel.chargeCD) { + pixel.charge = 1; + if (elements[pixel.element].colorOn) { + pixel.color = pixelColorPick(pixel); + } + } + } + else if (elements[pixel.element].insulate != true) { // Otherwise heat the pixel (Resistance simulation) + pixel.temp += 0.25; + pixelTempCheck(pixel); + } + } + } + } + else if (elements[currentElement].tool && !(elements[currentElement].canPlace && isEmpty(x,y))) { + // run the tool function on the pixel + if (!isEmpty(x,y,true)) { + var pixel = pixelMap[x][y]; + // if the current element has an ignore property and the pixel's element is in the ignore property, don't do anything + if (elements[currentElement].ignore && elements[currentElement].ignore.indexOf(pixel.element) != -1) { + continue; + } + elements[currentElement].tool(pixel); + } + } + else if (isEmpty(x, y)) { + if (survivalCount(currentElement) < 1 && elements[currentElement].category !== "tools") { + return; + } + currentPixels.push(new Pixel(x, y, currentElement)); + if (elements[currentElement].customColor || elements[currentElement].singleColor) { + pixelMap[x][y].color = pixelColorPick(currentElement,currentColor); + } + if (elements[currentElement].category !== "tools") { survivalRemove(currentElement,1); } + } + } + if (currentElement == "mix") { + for (var i = 0; i < mixList.length; i++) { + var pixel1 = mixList[Math.floor(Math.random()*mixList.length)]; + var pixel2 = mixList[Math.floor(Math.random()*mixList.length)]; + swapPixels(pixel1,pixel2); + mixList.splice(mixList.indexOf(pixel1),1); + mixList.splice(mixList.indexOf(pixel2),1); + if (elements[pixel1.element].onMix) { + elements[pixel1.element].onMix(pixel1,pixel2); + } + if (elements[pixel2.element].onMix) { + elements[pixel2.element].onMix(pixel2,pixel1); + } + } + + } + } + mouse2Action = function(e,mouseX=undefined,mouseY=undefined,startPos) { + // Erase pixel at mouse position + if (mouseX == undefined && mouseY == undefined) { + // var canvas = document.getElementById("game"); + // var ctx = canvas.getContext("2d"); + lastPos = mousePos; + mousePos = getMousePos(canvas, e); + var mouseX = mousePos.x; + var mouseY = mousePos.y; + } + if (dragStart) { + dragStart = 0; + for (var i = 0; i < draggingPixels.length; i++) { + var pixel = draggingPixels[i]; + delete pixel.drag; + } + draggingPixels = null; + } + // If the current element is "pick" or "lookup", coords = [mouseX,mouseY] + if (currentElement == "pick" || currentElement == "lookup") { + var coords = [[mouseX,mouseY]]; + } + else if (!isMobile) { + startPos = startPos || lastPos + var coords = lineCoords(startPos.x,startPos.y,mouseX,mouseY); + } + else { + var coords = mouseRange(mouseX,mouseY); + } + // For each x,y in coords + for (var i = 0; i < coords.length; i++) { + var x = coords[i][0]; + var y = coords[i][1]; + + if (!isEmpty(x, y)) { + if (outOfBounds(x,y)) { + continue + } + var pixel = pixelMap[x][y]; + survivalAdd(pixel.element,1); + delete pixelMap[x][y]; + // Remove pixel from currentPixels + for (var j = 0; j < currentPixels.length; j++) { + if (currentPixels[j].x == x && currentPixels[j].y == y) { + currentPixels.splice(j, 1); + break; + } + } + } + } + } +}) + +window.addEventListener("beforeunload",function(){ + clearAll(); + saveSettings(); +}); \ No newline at end of file From db0511f1df0992f6e425f873781f0c3d737c7aa3 Mon Sep 17 00:00:00 2001 From: GuyWhoGotSpringlocked <163777207+GWhoGS@users.noreply.github.com> Date: Sun, 14 Apr 2024 21:14:53 -0400 Subject: [PATCH 06/12] survival.js but cheating credits to Ryan for base game and survival.js --- mods/easysurvival.js | 399 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 399 insertions(+) diff --git a/mods/easysurvival.js b/mods/easysurvival.js index 9b8aba3f..86fdcc7b 100644 --- a/mods/easysurvival.js +++ b/mods/easysurvival.js @@ -1,3 +1,401 @@ +behaviors = { + POWDER_OLD: [ + "XX|XX|XX", + "XX|XX|XX", + "M2|M1|M2", + ], + POWDER: function(pixel) { + if (pixel.start === pixelTicks) {return} + if (pixel.charge && elements[pixel.element].behaviorOn) { + pixelTick(pixel) + } + if (!tryMove(pixel, pixel.x, pixel.y+1)) { + if (Math.random() < 0.5) { + if (!tryMove(pixel, pixel.x+1, pixel.y+1)) { + tryMove(pixel, pixel.x-1, pixel.y+1); + } + } else { + if (!tryMove(pixel, pixel.x-1, pixel.y+1)) { + tryMove(pixel, pixel.x+1, pixel.y+1); + } + } + } + doDefaults(pixel); + }, + AGPOWDER: [ + "M2|M1|M2", + "XX|XX|XX", + "XX|XX|XX", + ], + LIQUID_OLD: [ + "XX|XX|XX", + "M2|XX|M2", + "M1|M1|M1", + ], + LIQUID: function(pixel) { + if (pixel.start === pixelTicks) {return} + if (pixel.charge && elements[pixel.element].behaviorOn) { + pixelTick(pixel) + } + if (elements[pixel.element].viscosity && (!((Math.random()*100) < 100 / Math.pow(elements[pixel.element].viscosity, 0.25)))) { + var move1Spots = [ + [pixel.x, pixel.y+1] + ] + } + else { + var move1Spots = [ + [pixel.x+1, pixel.y+1], + [pixel.x, pixel.y+1], + [pixel.x-1, pixel.y+1], + ] + } + var moved = false; + for (var i = 0; i < move1Spots.length; i++) { + var coords = move1Spots[Math.floor(Math.random()*move1Spots.length)]; + if (tryMove(pixel, coords[0], coords[1])) { moved = true; break; } + else { move1Spots.splice(move1Spots.indexOf(coords), 1); } + } + if (!moved) { + if (elements[pixel.element].viscosity===undefined || !(!((Math.random()*100) < 100 / Math.pow(elements[pixel.element].viscosity, 0.25)))) { + if (Math.random() < 0.5) { + if (!tryMove(pixel, pixel.x+1, pixel.y)) { + tryMove(pixel, pixel.x-1, pixel.y); + } + } else { + if (!tryMove(pixel, pixel.x-1, pixel.y)) { + tryMove(pixel, pixel.x+1, pixel.y); + } + } + } + } + doDefaults(pixel); + }, + SUPERFLUID_OLD: [ + "XX|XX|XX", + "XX|XX|M2 AND BO", + "XX|M1|M2", + ], + SUPERFLUID: function(pixel) { + if (pixel.start === pixelTicks) {return} + if (pixel.charge && elements[pixel.element].behaviorOn) { + pixelTick(pixel) + } + if (!tryMove(pixel, pixel.x, pixel.y+1)) { + // go either left or right depending on pixel.flipX + var newx = pixel.flipX ? pixel.x-1 : pixel.x+1; + if (Math.random() < 0.5) { + if (!tryMove(pixel, newx, pixel.y)) { + pixel.flipX = !pixel.flipX; + tryMove(pixel, newx, pixel.y+1); + } + } + else { + if (!tryMove(pixel, newx, pixel.y+1)) { + if (!tryMove(pixel, newx, pixel.y)) { pixel.flipX = !pixel.flipX; } + } + } + } + doDefaults(pixel); + }, + LIGHTWEIGHT: [ + "XX|XX|XX", + "XX|FX%0.25|XX", + "M2%10|M1%10|M1%10", + ], + SLIDE: [ + "XX|XX|XX", + "XX|XX|M2 AND BO", + "XX|M1|M1", + ], + AGLIQUID: [ + "M1|M1|M1", + "M2|XX|M2", + "XX|XX|XX", + ], + WALL: [ + "XX|XX|XX", + "XX|XX|XX", + "XX|XX|XX", + ], + UL_UR: [ + "M1|M1|M1", + "M2|XX|M2", + "XX|M2|XX", + ], + UL_UR_OPTIMIZED: function(pixel) { + if (pixel.start === pixelTicks) {return} + if (pixel.charge && elements[pixel.element].behaviorOn) { + pixelTick(pixel) + } + var move1Spots = [ + [pixel.x, pixel.y-1], + [pixel.x+1, pixel.y-1], + [pixel.x-1, pixel.y-1], + ] + var moved = false; + for (var i = 0; i < move1Spots.length; i++) { + var coords = move1Spots[Math.floor(Math.random()*move1Spots.length)]; + if (tryMove(pixel, coords[0], coords[1])) { moved = true; break; } + else { move1Spots.splice(move1Spots.indexOf(coords), 1);} + } + if (!moved && !pixel.del) { + var move2Spots = [ + [pixel.x, pixel.y+1], + [pixel.x+1, pixel.y], + [pixel.x-1, pixel.y], + ] + for (var i = 0; i < move2Spots.length; i++) { + var coords = move2Spots[Math.floor(Math.random()*move2Spots.length)]; + if (tryMove(pixel, coords[0], coords[1])) { break; } + else { move2Spots.splice(move2Spots.indexOf(coords), 1); } + } + } + if (!pixel.del) { doDefaults(pixel); } + }, + GAS_OLD: [ + "M2|M1|M2", + "M1|XX|M1", + "M2|M1|M2", + ], + GAS: function(pixel) { + if (pixel.start === pixelTicks) {return} + if (pixel.charge && elements[pixel.element].behaviorOn) { + pixelTick(pixel) + } + var move1Spots = [ + [pixel.x, pixel.y+1], + [pixel.x, pixel.y-1], + [pixel.x+1, pixel.y], + [pixel.x-1, pixel.y], + ] + var moved = false; + for (var i = 0; i < move1Spots.length; i++) { + var coords = move1Spots[Math.floor(Math.random()*move1Spots.length)]; + if (tryMove(pixel, coords[0], coords[1])) { moved = true; break; } + else { move1Spots.splice(move1Spots.indexOf(coords), 1);} + } + if (!moved) { + var move2Spots = [ + [pixel.x+1, pixel.y+1], + [pixel.x-1, pixel.y+1], + [pixel.x+1, pixel.y-1], + [pixel.x-1, pixel.y-1], + ] + for (var i = 0; i < move2Spots.length; i++) { + var coords = move2Spots[Math.floor(Math.random()*move2Spots.length)]; + if (tryMove(pixel, coords[0], coords[1])) { break; } + else { move2Spots.splice(move2Spots.indexOf(coords), 1); } + } + } + doDefaults(pixel); + }, + DGAS: [ + "M2|M1|M2", + "M1|DL%5|M1", + "M2|M1|M2", + ], + SUPPORT: [ + "XX|XX|XX", + "SP|XX|SP", + "XX|M1|XX", + ], + SUPPORTPOWDER: [ + "XX|XX|XX", + "SP|XX|SP", + "M2|M1|M2", + ], + DELETE: [ + "XX|DL|XX", + "DL|XX|DL", + "XX|DL|XX", + ], + FILL: [ + "XX|CL|XX", + "CL|XX|CL", + "XX|CL|XX", + ], + CLONER: [ + "XX|CF|XX", + "CF|XX|CF", + "XX|CF|XX", + ], + SUPERCLONER: [ + "CF|CF|CF", + "CF|CF|CF", + "CF|CF|CF", + ], + STURDYPOWDER: [ + "XX|XX|XX", + "XX|XX|XX", + "XX|M1|XX", + ], + SELFDELETE: [ + "XX|XX|XX", + "XX|DL|XX", + "XX|XX|XX", + ], + FOAM: [ + "XX|XX|XX", + "XX|DL%5|XX", + "M2%25|M1%25|M2%25", + ], + BUBBLE: [ + "XX|XX|XX", + "XX|DL%0.25 AND FX%1|M1%5", + "XX|M1%1|M1%2", + ], + STICKY: [ + "XX|ST|XX", + "ST|XX|ST", + "XX|ST AND M1|XX", + ], + MOLTEN: [ + "XX|CR:fire%2.5|XX", + "M2|XX|M2", + "M1|M1|M1", + ], + RADPOWDER: [ + "XX|CR:radiation%1|XX", + "CR:radiation%1|XX|CR:radiation%1", + "M2|M1|M2", + ], + RADMOLTEN: [ + "XX|CR:fire,fire,fire,radiation%4.5|XX", + "M2 AND CR:radiation%1|XX|M2 AND CR:radiation%1", + "M1|M1|M1", + ], + RADLIQUID: [ + "XX|CR:radiation%2|XX", + "M2 AND CR:radiation%2|XX|M2 AND CR:radiation%2", + "M1|M1|M1", + ], + BOUNCY: function(pixel) { + if (pixel.bx===undefined) { + // choose 1, 0, or -1 + pixel.bx = Math.random() < 0.5 ? 1 : Math.random() < 0.5 ? 0 : -1; + pixel.by = Math.random() < 0.5 ? 1 : Math.random() < 0.5 ? 0 : -1; + // if both are 0, make one of them 1 or -1 + if (pixel.bx===0 && pixel.by===0) { + if (Math.random() < 0.5) { pixel.bx = Math.random() < 0.5 ? 1 : -1; } + else { pixel.by = Math.random() < 0.5 ? 1 : -1; } + } + } + // move and invert direction if hit + if (!pixel.del && pixel.bx && !tryMove(pixel, pixel.x+pixel.bx, pixel.y)) { pixel.bx = -pixel.bx; } + if (!pixel.del && pixel.by && !tryMove(pixel, pixel.x, pixel.y+pixel.by)) { pixel.by = -pixel.by; } + }, + FEEDPIXEL: function(pixel) { + if (!pixel.food) { pixel.food = 1 } + else { pixel.food ++ } + if (pixel.food > (elements[pixel.element].foodNeed||30)) { + // loop through adjacentCoords and check each pixel to lay an egg + for (var i = 0; i < adjacentCoords.length; i++) { + var x = pixel.x+adjacentCoords[i][0]; + var y = pixel.y+adjacentCoords[i][1]; + if (isEmpty(x, y)) { + if (elements[pixel.element].egg) { + createPixel(elements[pixel.element].egg,x,y) + } + else { + createPixel("egg",x,y) + pixelMap[x][y].animal = elements[pixel.element].baby || pixel.element; + if (elements[pixel.element].eggColor) { + pixelMap[x][y].color = pixelColorPick(pixelMap[x][y],elements[pixel.element].eggColor) + } + } + pixel.food = 0; + break; + } + } + } + }, + KILLPIXEL1: function(pixel) { + pixel.dead = true; + }, + KILLPIXEL2: function(pixel1,pixel2) { + pixel2.dead = true; + }, + FLY: function(pixel, onHit) { + var nx = pixel.flipX ? -1 : 1; + var ny = Math.random() < 0.5 ? -1 : 1; + var hit = false; + if (!tryMove(pixel, pixel.x+nx, pixel.y+ny)) { + if (!tryMove(pixel, pixel.x+nx, pixel.y-ny)) { + if (!tryMove(pixel, pixel.x, pixel.y+ny)) { + if (!tryMove(pixel, pixel.x, pixel.y-ny)) {hit=[pixel.x, pixel.y-ny]} + }else {hit=[pixel.x, pixel.y+ny]} + }else {hit=[pixel.x+nx, pixel.y-ny]} + }else {hit=[pixel.x+nx, pixel.y+ny]} + if (hit && onHit) { + if (!isEmpty(hit[0], hit[1], true)) { + onHit(pixel, pixelMap[hit[0]][hit[1]]); + } + else {onHit(pixel);} + } + if (pixel.del) {return} + if (!isEmpty(pixel.x+nx,pixel.y) || Math.random() < 0.02) { + pixel.flipX = !pixel.flipX; + } + if (pixel.charge && elements[pixel.element].behaviorOn) { + pixelTick(pixel) + } + doDefaults(pixel); + }, + CRAWLER: function(pixel) { + if (Math.random() < 0.08) { // flip + pixel.flipX = !pixel.flipX; + } + var dir = pixel.flipX ? -1 : 1; + var dirY = pixel.flipY ? -1 : 1; + if (!tryMove(pixel,pixel.x,pixel.y+dirY)) { // fall or climb + if (!tryMove(pixel,pixel.x+dir,pixel.y)) { // hits wall + if (!pixel.hilled && !isEmpty(pixel.x+dir,pixel.y,true) && pixelMap[pixel.x+dir][pixel.y].element === "ant_wall") { + pixel.hilled = true; + } + tryMove(pixel,pixel.x+dir,pixel.y + (Math.random() < 0.25 ? 1 : -1)); + } + if (Math.random() < 0.01 && !isEmpty(pixel.x+dir,pixel.y+1,true) && eLists.CRAWLTHRU.indexOf(pixelMap[pixel.x+dir][pixel.y+1].element) !== -1) { + if (!pixel.hilled || !isEmpty(pixel.x+dir,pixel.y,true) && pixelMap[pixel.x+dir][pixel.y].element === "ant_wall") { + var wallCoords = [ + [-1,-1],[1,-1], + [-1,0],[1,0], + [0,1] + ]; + if (!isEmpty(pixel.x,pixel.y-2)) { + wallCoords.push([0,-1]) + } + if (Math.random() < 0.15) { wallCoords.push([-1,1]) } + if (Math.random() < 0.15) { wallCoords.push([1,1]) } + // loop through wallCoords, change pixel to ant_wall if in crawlthru + for (var i = 0; i < wallCoords.length; i++) { + var x = pixel.x+dir+wallCoords[i][0]; + var y = pixel.y+1+wallCoords[i][1]; + if (!isEmpty(x,y,true) && eLists.CRAWLTHRU.indexOf(pixelMap[x][y].element) !== -1) { + changePixel(pixelMap[x][y],"ant_wall"); + } + } + deletePixel(pixel.x+dir,pixel.y+1); + tryMove(pixel,pixel.x+dir,pixel.y+1); + } + } + else if (Math.random() < 0.08 && !isEmpty(pixel.x+dir,pixel.y-1,true) && eLists.CRAWLTHRU.indexOf(pixelMap[pixel.x+dir][pixel.y-1].element) !== -1) { + swapPixels(pixel,pixelMap[pixel.x+dir][pixel.y-1]); + } + } + doDefaults(pixel); + } +} + +elements.supercloner = { + color: "#dddd00", + behavior: behaviors.SUPERCLONER, + ignore: ["ecloner","slow_cloner","clone_powder","floating_cloner","wall","ewall", "cloner"], + category:"inventory", + insulate:true, + hardness: 1, + darkText: true, +} + if (!settings.survival) { settings.survival = { "wall": 9999, @@ -6,6 +404,7 @@ if (!settings.survival) { "seeds": 50, "ice": 250, "cloner": 10, + "supercloner": 10 } } settings.survival.cloner = 1; From 51b7bc93f6e973c2b5e4a6a74f8f5589f1e15a6a Mon Sep 17 00:00:00 2001 From: GuyWhoGotSpringlocked <163777207+GWhoGS@users.noreply.github.com> Date: Sun, 14 Apr 2024 21:17:29 -0400 Subject: [PATCH 07/12] Delete easysurvival.js extra one ig --- easysurvival.js | 917 ------------------------------------------------ 1 file changed, 917 deletions(-) delete mode 100644 easysurvival.js diff --git a/easysurvival.js b/easysurvival.js deleted file mode 100644 index 86fdcc7b..00000000 --- a/easysurvival.js +++ /dev/null @@ -1,917 +0,0 @@ -behaviors = { - POWDER_OLD: [ - "XX|XX|XX", - "XX|XX|XX", - "M2|M1|M2", - ], - POWDER: function(pixel) { - if (pixel.start === pixelTicks) {return} - if (pixel.charge && elements[pixel.element].behaviorOn) { - pixelTick(pixel) - } - if (!tryMove(pixel, pixel.x, pixel.y+1)) { - if (Math.random() < 0.5) { - if (!tryMove(pixel, pixel.x+1, pixel.y+1)) { - tryMove(pixel, pixel.x-1, pixel.y+1); - } - } else { - if (!tryMove(pixel, pixel.x-1, pixel.y+1)) { - tryMove(pixel, pixel.x+1, pixel.y+1); - } - } - } - doDefaults(pixel); - }, - AGPOWDER: [ - "M2|M1|M2", - "XX|XX|XX", - "XX|XX|XX", - ], - LIQUID_OLD: [ - "XX|XX|XX", - "M2|XX|M2", - "M1|M1|M1", - ], - LIQUID: function(pixel) { - if (pixel.start === pixelTicks) {return} - if (pixel.charge && elements[pixel.element].behaviorOn) { - pixelTick(pixel) - } - if (elements[pixel.element].viscosity && (!((Math.random()*100) < 100 / Math.pow(elements[pixel.element].viscosity, 0.25)))) { - var move1Spots = [ - [pixel.x, pixel.y+1] - ] - } - else { - var move1Spots = [ - [pixel.x+1, pixel.y+1], - [pixel.x, pixel.y+1], - [pixel.x-1, pixel.y+1], - ] - } - var moved = false; - for (var i = 0; i < move1Spots.length; i++) { - var coords = move1Spots[Math.floor(Math.random()*move1Spots.length)]; - if (tryMove(pixel, coords[0], coords[1])) { moved = true; break; } - else { move1Spots.splice(move1Spots.indexOf(coords), 1); } - } - if (!moved) { - if (elements[pixel.element].viscosity===undefined || !(!((Math.random()*100) < 100 / Math.pow(elements[pixel.element].viscosity, 0.25)))) { - if (Math.random() < 0.5) { - if (!tryMove(pixel, pixel.x+1, pixel.y)) { - tryMove(pixel, pixel.x-1, pixel.y); - } - } else { - if (!tryMove(pixel, pixel.x-1, pixel.y)) { - tryMove(pixel, pixel.x+1, pixel.y); - } - } - } - } - doDefaults(pixel); - }, - SUPERFLUID_OLD: [ - "XX|XX|XX", - "XX|XX|M2 AND BO", - "XX|M1|M2", - ], - SUPERFLUID: function(pixel) { - if (pixel.start === pixelTicks) {return} - if (pixel.charge && elements[pixel.element].behaviorOn) { - pixelTick(pixel) - } - if (!tryMove(pixel, pixel.x, pixel.y+1)) { - // go either left or right depending on pixel.flipX - var newx = pixel.flipX ? pixel.x-1 : pixel.x+1; - if (Math.random() < 0.5) { - if (!tryMove(pixel, newx, pixel.y)) { - pixel.flipX = !pixel.flipX; - tryMove(pixel, newx, pixel.y+1); - } - } - else { - if (!tryMove(pixel, newx, pixel.y+1)) { - if (!tryMove(pixel, newx, pixel.y)) { pixel.flipX = !pixel.flipX; } - } - } - } - doDefaults(pixel); - }, - LIGHTWEIGHT: [ - "XX|XX|XX", - "XX|FX%0.25|XX", - "M2%10|M1%10|M1%10", - ], - SLIDE: [ - "XX|XX|XX", - "XX|XX|M2 AND BO", - "XX|M1|M1", - ], - AGLIQUID: [ - "M1|M1|M1", - "M2|XX|M2", - "XX|XX|XX", - ], - WALL: [ - "XX|XX|XX", - "XX|XX|XX", - "XX|XX|XX", - ], - UL_UR: [ - "M1|M1|M1", - "M2|XX|M2", - "XX|M2|XX", - ], - UL_UR_OPTIMIZED: function(pixel) { - if (pixel.start === pixelTicks) {return} - if (pixel.charge && elements[pixel.element].behaviorOn) { - pixelTick(pixel) - } - var move1Spots = [ - [pixel.x, pixel.y-1], - [pixel.x+1, pixel.y-1], - [pixel.x-1, pixel.y-1], - ] - var moved = false; - for (var i = 0; i < move1Spots.length; i++) { - var coords = move1Spots[Math.floor(Math.random()*move1Spots.length)]; - if (tryMove(pixel, coords[0], coords[1])) { moved = true; break; } - else { move1Spots.splice(move1Spots.indexOf(coords), 1);} - } - if (!moved && !pixel.del) { - var move2Spots = [ - [pixel.x, pixel.y+1], - [pixel.x+1, pixel.y], - [pixel.x-1, pixel.y], - ] - for (var i = 0; i < move2Spots.length; i++) { - var coords = move2Spots[Math.floor(Math.random()*move2Spots.length)]; - if (tryMove(pixel, coords[0], coords[1])) { break; } - else { move2Spots.splice(move2Spots.indexOf(coords), 1); } - } - } - if (!pixel.del) { doDefaults(pixel); } - }, - GAS_OLD: [ - "M2|M1|M2", - "M1|XX|M1", - "M2|M1|M2", - ], - GAS: function(pixel) { - if (pixel.start === pixelTicks) {return} - if (pixel.charge && elements[pixel.element].behaviorOn) { - pixelTick(pixel) - } - var move1Spots = [ - [pixel.x, pixel.y+1], - [pixel.x, pixel.y-1], - [pixel.x+1, pixel.y], - [pixel.x-1, pixel.y], - ] - var moved = false; - for (var i = 0; i < move1Spots.length; i++) { - var coords = move1Spots[Math.floor(Math.random()*move1Spots.length)]; - if (tryMove(pixel, coords[0], coords[1])) { moved = true; break; } - else { move1Spots.splice(move1Spots.indexOf(coords), 1);} - } - if (!moved) { - var move2Spots = [ - [pixel.x+1, pixel.y+1], - [pixel.x-1, pixel.y+1], - [pixel.x+1, pixel.y-1], - [pixel.x-1, pixel.y-1], - ] - for (var i = 0; i < move2Spots.length; i++) { - var coords = move2Spots[Math.floor(Math.random()*move2Spots.length)]; - if (tryMove(pixel, coords[0], coords[1])) { break; } - else { move2Spots.splice(move2Spots.indexOf(coords), 1); } - } - } - doDefaults(pixel); - }, - DGAS: [ - "M2|M1|M2", - "M1|DL%5|M1", - "M2|M1|M2", - ], - SUPPORT: [ - "XX|XX|XX", - "SP|XX|SP", - "XX|M1|XX", - ], - SUPPORTPOWDER: [ - "XX|XX|XX", - "SP|XX|SP", - "M2|M1|M2", - ], - DELETE: [ - "XX|DL|XX", - "DL|XX|DL", - "XX|DL|XX", - ], - FILL: [ - "XX|CL|XX", - "CL|XX|CL", - "XX|CL|XX", - ], - CLONER: [ - "XX|CF|XX", - "CF|XX|CF", - "XX|CF|XX", - ], - SUPERCLONER: [ - "CF|CF|CF", - "CF|CF|CF", - "CF|CF|CF", - ], - STURDYPOWDER: [ - "XX|XX|XX", - "XX|XX|XX", - "XX|M1|XX", - ], - SELFDELETE: [ - "XX|XX|XX", - "XX|DL|XX", - "XX|XX|XX", - ], - FOAM: [ - "XX|XX|XX", - "XX|DL%5|XX", - "M2%25|M1%25|M2%25", - ], - BUBBLE: [ - "XX|XX|XX", - "XX|DL%0.25 AND FX%1|M1%5", - "XX|M1%1|M1%2", - ], - STICKY: [ - "XX|ST|XX", - "ST|XX|ST", - "XX|ST AND M1|XX", - ], - MOLTEN: [ - "XX|CR:fire%2.5|XX", - "M2|XX|M2", - "M1|M1|M1", - ], - RADPOWDER: [ - "XX|CR:radiation%1|XX", - "CR:radiation%1|XX|CR:radiation%1", - "M2|M1|M2", - ], - RADMOLTEN: [ - "XX|CR:fire,fire,fire,radiation%4.5|XX", - "M2 AND CR:radiation%1|XX|M2 AND CR:radiation%1", - "M1|M1|M1", - ], - RADLIQUID: [ - "XX|CR:radiation%2|XX", - "M2 AND CR:radiation%2|XX|M2 AND CR:radiation%2", - "M1|M1|M1", - ], - BOUNCY: function(pixel) { - if (pixel.bx===undefined) { - // choose 1, 0, or -1 - pixel.bx = Math.random() < 0.5 ? 1 : Math.random() < 0.5 ? 0 : -1; - pixel.by = Math.random() < 0.5 ? 1 : Math.random() < 0.5 ? 0 : -1; - // if both are 0, make one of them 1 or -1 - if (pixel.bx===0 && pixel.by===0) { - if (Math.random() < 0.5) { pixel.bx = Math.random() < 0.5 ? 1 : -1; } - else { pixel.by = Math.random() < 0.5 ? 1 : -1; } - } - } - // move and invert direction if hit - if (!pixel.del && pixel.bx && !tryMove(pixel, pixel.x+pixel.bx, pixel.y)) { pixel.bx = -pixel.bx; } - if (!pixel.del && pixel.by && !tryMove(pixel, pixel.x, pixel.y+pixel.by)) { pixel.by = -pixel.by; } - }, - FEEDPIXEL: function(pixel) { - if (!pixel.food) { pixel.food = 1 } - else { pixel.food ++ } - if (pixel.food > (elements[pixel.element].foodNeed||30)) { - // loop through adjacentCoords and check each pixel to lay an egg - for (var i = 0; i < adjacentCoords.length; i++) { - var x = pixel.x+adjacentCoords[i][0]; - var y = pixel.y+adjacentCoords[i][1]; - if (isEmpty(x, y)) { - if (elements[pixel.element].egg) { - createPixel(elements[pixel.element].egg,x,y) - } - else { - createPixel("egg",x,y) - pixelMap[x][y].animal = elements[pixel.element].baby || pixel.element; - if (elements[pixel.element].eggColor) { - pixelMap[x][y].color = pixelColorPick(pixelMap[x][y],elements[pixel.element].eggColor) - } - } - pixel.food = 0; - break; - } - } - } - }, - KILLPIXEL1: function(pixel) { - pixel.dead = true; - }, - KILLPIXEL2: function(pixel1,pixel2) { - pixel2.dead = true; - }, - FLY: function(pixel, onHit) { - var nx = pixel.flipX ? -1 : 1; - var ny = Math.random() < 0.5 ? -1 : 1; - var hit = false; - if (!tryMove(pixel, pixel.x+nx, pixel.y+ny)) { - if (!tryMove(pixel, pixel.x+nx, pixel.y-ny)) { - if (!tryMove(pixel, pixel.x, pixel.y+ny)) { - if (!tryMove(pixel, pixel.x, pixel.y-ny)) {hit=[pixel.x, pixel.y-ny]} - }else {hit=[pixel.x, pixel.y+ny]} - }else {hit=[pixel.x+nx, pixel.y-ny]} - }else {hit=[pixel.x+nx, pixel.y+ny]} - if (hit && onHit) { - if (!isEmpty(hit[0], hit[1], true)) { - onHit(pixel, pixelMap[hit[0]][hit[1]]); - } - else {onHit(pixel);} - } - if (pixel.del) {return} - if (!isEmpty(pixel.x+nx,pixel.y) || Math.random() < 0.02) { - pixel.flipX = !pixel.flipX; - } - if (pixel.charge && elements[pixel.element].behaviorOn) { - pixelTick(pixel) - } - doDefaults(pixel); - }, - CRAWLER: function(pixel) { - if (Math.random() < 0.08) { // flip - pixel.flipX = !pixel.flipX; - } - var dir = pixel.flipX ? -1 : 1; - var dirY = pixel.flipY ? -1 : 1; - if (!tryMove(pixel,pixel.x,pixel.y+dirY)) { // fall or climb - if (!tryMove(pixel,pixel.x+dir,pixel.y)) { // hits wall - if (!pixel.hilled && !isEmpty(pixel.x+dir,pixel.y,true) && pixelMap[pixel.x+dir][pixel.y].element === "ant_wall") { - pixel.hilled = true; - } - tryMove(pixel,pixel.x+dir,pixel.y + (Math.random() < 0.25 ? 1 : -1)); - } - if (Math.random() < 0.01 && !isEmpty(pixel.x+dir,pixel.y+1,true) && eLists.CRAWLTHRU.indexOf(pixelMap[pixel.x+dir][pixel.y+1].element) !== -1) { - if (!pixel.hilled || !isEmpty(pixel.x+dir,pixel.y,true) && pixelMap[pixel.x+dir][pixel.y].element === "ant_wall") { - var wallCoords = [ - [-1,-1],[1,-1], - [-1,0],[1,0], - [0,1] - ]; - if (!isEmpty(pixel.x,pixel.y-2)) { - wallCoords.push([0,-1]) - } - if (Math.random() < 0.15) { wallCoords.push([-1,1]) } - if (Math.random() < 0.15) { wallCoords.push([1,1]) } - // loop through wallCoords, change pixel to ant_wall if in crawlthru - for (var i = 0; i < wallCoords.length; i++) { - var x = pixel.x+dir+wallCoords[i][0]; - var y = pixel.y+1+wallCoords[i][1]; - if (!isEmpty(x,y,true) && eLists.CRAWLTHRU.indexOf(pixelMap[x][y].element) !== -1) { - changePixel(pixelMap[x][y],"ant_wall"); - } - } - deletePixel(pixel.x+dir,pixel.y+1); - tryMove(pixel,pixel.x+dir,pixel.y+1); - } - } - else if (Math.random() < 0.08 && !isEmpty(pixel.x+dir,pixel.y-1,true) && eLists.CRAWLTHRU.indexOf(pixelMap[pixel.x+dir][pixel.y-1].element) !== -1) { - swapPixels(pixel,pixelMap[pixel.x+dir][pixel.y-1]); - } - } - doDefaults(pixel); - } -} - -elements.supercloner = { - color: "#dddd00", - behavior: behaviors.SUPERCLONER, - ignore: ["ecloner","slow_cloner","clone_powder","floating_cloner","wall","ewall", "cloner"], - category:"inventory", - insulate:true, - hardness: 1, - darkText: true, -} - -if (!settings.survival) { - settings.survival = { - "wall": 9999, - "dirt": 9999, - "sapling": 10, - "seeds": 50, - "ice": 250, - "cloner": 10, - "supercloner": 10 - } -} -settings.survival.cloner = 1; -settings.unhide = 0; -// settings.survivalClone=null; settings.survival = null; saveSettings(); - -survivalTimeout = null; -function survivalSave() { - if (survivalTimeout) { clearTimeout(survivalTimeout); } - survivalTimeout = setTimeout(function(){ - saveSettings(); - },1000); -} -function survivalAdd(element,amount,skipSave) { - if (elements[element].category === "tools") { return } - if (settings.survival[element]) { - settings.survival[element] += amount; - } - else { - settings.survival[element] = amount; - } - survivalUpdate(element); - if (!skipSave) {survivalSave()} -} -function survivalRemove(element,amount,skipSave) { - if (elements[element].category === "tools") { return } - if (settings.survival[element]) { - settings.survival[element] -= amount; - survivalUpdate(element); - } - if (settings.survival[element] <= 0) { - delete settings.survival[element]; - var btn = document.getElementById("elementButton-"+element); - if (btn) { btn.remove(); } - selectElement("unknown"); - } - if (!skipSave) {survivalSave()} -} -function survivalCount(element) { - return settings.survival[element] || 0; -} -function survivalUpdate(element) { - if (element === "gold_coin") { - // if it is not an integer, round it to 0.1 - if (settings.survival.gold_coin % 1 !== 0) { - settings.survival.gold_coin = Math.round(settings.survival.gold_coin*10)/10; - } - document.getElementById("coinCount").innerHTML = settings.survival.gold_coin||0; - } - var btn = document.getElementById("elementButton-"+element); - if (elements[element] && elements[element].category === "tools") { return } - if (btn) { - btn.innerHTML = btn.innerHTML.split("(")[0]+"("+settings.survival[element]+")"; - } - else if (elements[element]) { - createElementButton(element); - document.getElementById("elementButton-"+element).innerHTML += "("+settings.survival[element]+")"; - } -} - -runAfterAutogen(function(){ - elements.erase.name = "pick_up"; - delete elements.paint.category; - delete elements.lookup.category; - delete elements.pick; - delete elements.prop; - elements.radiation.category = "tools"; - for (var element in elements) { - if (elements[element].category !== "tools") { - elements[element].hidden = true; - elements[element].category = "inventory"; - } - } - for (var element in settings.survival) { - if (!elements[element]) { continue; } - if (elements[element].category === "tools") { continue; } - createElementButton(element); - document.getElementById("elementButton-"+element).innerHTML += "("+settings.survival[element]+")"; - } -}); - -delete elements.cloner.behavior; -elements.cloner.tick = function(pixel) { - if (settings.survivalClone) { - if (Math.random() < 0.025) { - // 1 or -1 - var x = pixel.x + (Math.random() < 0.5 ? 1 : -1); - var y = pixel.y + (Math.random() < 0.5 ? 1 : -1); - if (isEmpty(x,y)) { - createPixel(settings.survivalClone,x,y); - } - } - } - else { - for (var i = 0; i < adjacentCoords.length; i++) { - var coords = adjacentCoords[i]; - var x = pixel.x + coords[0]; - var y = pixel.y + coords[1]; - if (!isEmpty(x,y,true)) { - if (pixelMap[x][y].clone) { pixel.clone = pixelMap[x][y].clone; break } - var element = pixelMap[x][y].element; - if (element === pixel.element || elements[pixel.element].ignore.indexOf(element) !== -1) { continue } - settings.survivalClone = element; - survivalSave(); - break; - } - } - } -}; -elements.cloner.ignore = elements.cloner.ignore.concat(["sun","supernova"]); -elements.cloner.desc = "You can only clone one element at a time!" - -elements.smash.tool = function(pixel) { - if (elements[pixel.element].seed === true) { return } - if (elements[pixel.element].breakInto !== undefined || (elements[pixel.element].seed !== undefined && elements[pixel.element].seed !== true)) { - // times 0.25 if not shiftDown else 1 - if (Math.random() < (elements[pixel.element].hardness || 1) * (shiftDown ? 1 : 0.25)) { - var breakInto = elements[pixel.element].breakInto; - if (elements[pixel.element].seed && (!breakInto || Math.random() < 0.5)) { - if (Math.random() < 0.2) { - breakInto = elements[pixel.element].seed; - } - else { - breakInto = null; - } - } - // if breakInto is an array, pick one - if (Array.isArray(breakInto)) { - breakInto = breakInto[Math.floor(Math.random() * breakInto.length)]; - } - if (breakInto === null) { - deletePixel(pixel.x,pixel.y); - return; - } - var oldelement = pixel.element; - changePixel(pixel,breakInto); - pixelTempCheck(pixel); - if (elements[oldelement].breakIntoColor) { - pixel.color = pixelColorPick(pixel, elements[oldelement].breakIntoColor); - } - } - } -}; - -elementWorth = { - "gold_coin": 1, - "diamond": 1000^21, - "ketchup": 150, - "jelly": 120, - "soda": 104, - "toast": 120, - "oil": 1023423, - "bread": 32, - "glass": 54, - "rad_glass": 64, - "glass_shard": 42, - "rad_shard": 312412, - "paper": 512312, - "broth": 512312, - "honey": 125, - "caramel": 53, - "sap": 34, - "candy": 325, - "popcorn": 232, - "flour": 322, - "lettuce": 2232, - "sauce": 2232, - "wood": 999, - "tree_branch": 100000, - "plant": 1, - "mushroom_cap": 1, - "mushroom_gill": 3, - "vine": 1, - "cactus": 1, - "cloner": 2, - "wall": 1000^22, - "fire": 100000^232, - "smoke": 0, - "plasma": 0, - "light": 0, - "laser": 0, - "liquid_light": 0.1, - "flash": 0, - "radiation": 0, - "petal": -1, - "cell": -1, - "cancer": -1, - "foam": -1, -} -elements.sell = { - color: ["#fff0b5","#ffe680","#c48821","#986a1a","#eca832","#f0bb62"], - tool: function(pixel) { - if (elementWorth[pixel.element] === 0) { return; } - deletePixel(pixel.x,pixel.y); - if (elementWorth[pixel.element] === -1) { return; } - survivalAdd("gold_coin",elementWorth*10[pixel.element]||1); - }, - category: "tools", - desc: "Exchanges pixels for their market value in Gold Coins x 10" -} -elements.seeds.name = "seed"; - -/* -~Cloner -~Sell -Shop - Cloner Reset - ~Ammonia - ~Dirt - ~Water - ~Seeds - ~Sapling - ~Pinecone - ~Primordial Soup - ~Worm - ~Bee - ~Human - ~TNT - Seller (Runs Sell tool on pixels that touch it) - Buyer (Cloner but uses store price every time, prompt to select item on select) -Prices tab -*/ -survivalShop = { - "dirt*25": 25, - "water*25": 250, - "ammonia*25": 500, - "seeds*1": 500, - "sapling*1": 500, - "pinecone*1": 500, - "tnt*25": 1000, - "worm*1": 1000, - "bee*1": 5000, - "primordial_soup*5": 10000, - "human*1": 50000, - "sun*1": 500000, - "milk": -200^2, -} -function survivalBuy(element) { - var price = survivalShop[element]; - if (!price) { alert("The shop isn't selling "+element+"!"); return } - if (!settings.survival.gold_coin || settings.survival.gold_coin < price) { alert("You can't afford that!"); return } - survivalRemove("gold_coin",price); - var amount = 1; - if (element.indexOf("*") !== -1) { amount = parseInt(element.split("*")[1]); element = element.split("*")[0]; } - survivalAdd(element,amount); - selectElement(element); -} -function survivalResetCloner() { - if (!settings.survival.gold_coin || settings.survival.gold_coin < 1000) { alert("You can't afford that!"); return } - survivalRemove("gold_coin",1000); - settings.survivalClone = null; - survivalSave(); -} - -worldgentypes = {} -window.addEventListener("load",function(){ - // move to start of tools - var erase = document.getElementById("elementButton-erase"); - var sell = document.getElementById("elementButton-sell"); - var parent = erase.parentElement; - parent.removeChild(sell); - parent.insertBefore(sell,parent.firstChild); - parent.removeChild(erase); - parent.insertBefore(erase,parent.firstChild); - document.getElementById("replaceButton").remove(); - document.getElementById("savesButton").remove(); - document.getElementById("elemSelectButton").remove(); - doRandomEvents = function() {} - worldGen = function() {} - worldgentypes = {} - loadSave = function() {} - showSaves = function() {} - placeImage = function() {} - chooseElementPrompt = function() {} - document.getElementById("toolControls").insertAdjacentHTML("beforeend",``); - createCategoryDiv("shop"); - var shopDiv = document.getElementById("category-shop"); - shopDiv.style.display = "none"; - shopDiv.insertAdjacentHTML("beforeend",`

You have $${settings.survival.gold_coin||0}

`); - for (var element in survivalShop) { - var price = survivalShop[element]; - var button = document.createElement("button"); - var name = element; - var amount = 1; - if (element.indexOf("*") !== -1) { amount = parseInt(element.split("*")[1]); name = element.split("*")[0]; } - var elemname = name; - name = (elements[elemname].name||name).replace(/_/g, " ").replace("."," ").replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}).replace(" ",".").replace(/ /g, ""); - button.classList.add("elementButton"); - button.setAttribute("element",element); - button.setAttribute("category","shop"); - button.setAttribute("title",amount+" "+name+" for $"+price); - button.innerHTML = name+" ("+amount+" for $"+price+")"; - if (elements[elemname]) { - if (elements[elemname].color instanceof Array) { - button.style.backgroundImage = "linear-gradient(to bottom right, "+elements[elemname].color.join(", ")+")"; - // choose the middlemost item in array - var colorObject = elements[elemname].colorObject[Math.floor(elements[elemname].colorObject.length/2)]; - if (elements[elemname].darkText !== false && (elements[elemname].darkText || (colorObject.r+colorObject.g+colorObject.b)/3 > 200)) { - button.className += " bright" - } - } - else { - button.style.background = elements[elemname].color; - var colorObject = elements[elemname].colorObject; - if (elements[elemname].darkText !== false && (elements[elemname].darkText || (colorObject.r+colorObject.g+colorObject.b)/3 > 200)) { - button.className += " bright" - } - } - } - button.addEventListener("click",function(){ - survivalBuy(this.getAttribute("element")); - }); - shopDiv.appendChild(button); - } - shopDiv.insertAdjacentHTML("beforeend",`

`); - - createCategoryDiv("prices"); - var pricesDiv = document.getElementById("category-prices"); - pricesDiv.style.display = "none"; - for (var element in elementWorth) { - if (elementWorth[element] <= 0) { continue } - var name = (elements[element].name||element).replace(/_/g, " ").replace("."," ").replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}).replace(" ","."); - // create text with the name of the element and its worth, separated by • - var text = name+"="+elementWorth[element] + " • "; - pricesDiv.insertAdjacentHTML("beforeend",`${text}`); - } - pricesDiv.innerHTML = pricesDiv.innerHTML.slice(0,-2); - pricesDiv.innerHTML = "

"+pricesDiv.innerHTML+"

"; -}); -runAfterLoad(function(){ - checkUnlock = function(element) { - return; - } - oldClearAll = clearAll; - clearAll = function() { - if (currentPixels && currentPixels.length > 0) { - for (var i = 0; i < currentPixels.length; i++) { - var pixel = currentPixels[i]; - if (pixel && pixel.element) { - survivalAdd(pixel.element,1); - } - } - } - oldClearAll(); - } - mouseAction = function(e,mouseX,mouseY,startPos) { - if (mouseType == "left") { - mouse1Action(e,mouseX,mouseY,startPos); - } - else if (mouseType == "right") { mouse2Action(e,mouseX,mouseY,startPos); } - else if (mouseType == "middle") { mouseMiddleAction(e,mouseX,mouseY); } - } - mouse1Action = function(e,mouseX=undefined,mouseY=undefined,startPos) { - if (currentElement === "erase") { mouse2Action(e,mouseX,mouseY); return; } - else if (currentElement === "pick") { mouseMiddleAction(e,mouseX,mouseY); return; } - // If x and y are undefined, get the mouse position - if (mouseX == undefined && mouseY == undefined) { - // var canvas = document.getElementById("game"); - // var ctx = canvas.getContext("2d"); - lastPos = mousePos; - mousePos = getMousePos(canvas, e); - var mouseX = mousePos.x; - var mouseY = mousePos.y; - } - var cooldowned = false; - if ((mouseSize===1 || elements[currentElement].maxSize===1) && elements[currentElement].cooldown) { - if (pixelTicks-lastPlace < elements[currentElement].cooldown) { - return; - } - cooldowned = true; - } - lastPlace = pixelTicks; - startPos = startPos || lastPos - if (!(isMobile || (cooldowned && startPos.x===lastPos.x && startPos.y===lastPos.y) || elements[currentElement].tool || elements[currentElement].category==="tools")) { - var coords = lineCoords(startPos.x,startPos.y,mouseX,mouseY); - } - else { var coords = mouseRange(mouseX,mouseY); } - var element = elements[currentElement]; - var mixList = []; - // For each x,y in coords - for (var i = 0; i < coords.length; i++) { - var x = coords[i][0]; - var y = coords[i][1]; - - if (currentElement === "mix") { - if (!isEmpty(x,y,true)) { - var pixel = pixelMap[x][y]; - if (!(elements[pixel.element].movable !== true || elements[pixel.element].noMix === true) || shiftDown) { - mixList.push(pixel); - } - } - } - else if (currentElement === "shock") { - if (!isEmpty(x,y,true)) { - // One loop that repeats 5 times if shiftDown else 1 time - for (var j = 0; j < (shiftDown ? 5 : 1); j++) { - var pixel = pixelMap[x][y]; - var con = elements[pixel.element].conduct; - if (con == undefined) {continue} - if (Math.random() < con) { // If random number is less than conductivity - if (!pixel.charge && !pixel.chargeCD) { - pixel.charge = 1; - if (elements[pixel.element].colorOn) { - pixel.color = pixelColorPick(pixel); - } - } - } - else if (elements[pixel.element].insulate != true) { // Otherwise heat the pixel (Resistance simulation) - pixel.temp += 0.25; - pixelTempCheck(pixel); - } - } - } - } - else if (elements[currentElement].tool && !(elements[currentElement].canPlace && isEmpty(x,y))) { - // run the tool function on the pixel - if (!isEmpty(x,y,true)) { - var pixel = pixelMap[x][y]; - // if the current element has an ignore property and the pixel's element is in the ignore property, don't do anything - if (elements[currentElement].ignore && elements[currentElement].ignore.indexOf(pixel.element) != -1) { - continue; - } - elements[currentElement].tool(pixel); - } - } - else if (isEmpty(x, y)) { - if (survivalCount(currentElement) < 1 && elements[currentElement].category !== "tools") { - return; - } - currentPixels.push(new Pixel(x, y, currentElement)); - if (elements[currentElement].customColor || elements[currentElement].singleColor) { - pixelMap[x][y].color = pixelColorPick(currentElement,currentColor); - } - if (elements[currentElement].category !== "tools") { survivalRemove(currentElement,1); } - } - } - if (currentElement == "mix") { - for (var i = 0; i < mixList.length; i++) { - var pixel1 = mixList[Math.floor(Math.random()*mixList.length)]; - var pixel2 = mixList[Math.floor(Math.random()*mixList.length)]; - swapPixels(pixel1,pixel2); - mixList.splice(mixList.indexOf(pixel1),1); - mixList.splice(mixList.indexOf(pixel2),1); - if (elements[pixel1.element].onMix) { - elements[pixel1.element].onMix(pixel1,pixel2); - } - if (elements[pixel2.element].onMix) { - elements[pixel2.element].onMix(pixel2,pixel1); - } - } - - } - } - mouse2Action = function(e,mouseX=undefined,mouseY=undefined,startPos) { - // Erase pixel at mouse position - if (mouseX == undefined && mouseY == undefined) { - // var canvas = document.getElementById("game"); - // var ctx = canvas.getContext("2d"); - lastPos = mousePos; - mousePos = getMousePos(canvas, e); - var mouseX = mousePos.x; - var mouseY = mousePos.y; - } - if (dragStart) { - dragStart = 0; - for (var i = 0; i < draggingPixels.length; i++) { - var pixel = draggingPixels[i]; - delete pixel.drag; - } - draggingPixels = null; - } - // If the current element is "pick" or "lookup", coords = [mouseX,mouseY] - if (currentElement == "pick" || currentElement == "lookup") { - var coords = [[mouseX,mouseY]]; - } - else if (!isMobile) { - startPos = startPos || lastPos - var coords = lineCoords(startPos.x,startPos.y,mouseX,mouseY); - } - else { - var coords = mouseRange(mouseX,mouseY); - } - // For each x,y in coords - for (var i = 0; i < coords.length; i++) { - var x = coords[i][0]; - var y = coords[i][1]; - - if (!isEmpty(x, y)) { - if (outOfBounds(x,y)) { - continue - } - var pixel = pixelMap[x][y]; - survivalAdd(pixel.element,1); - delete pixelMap[x][y]; - // Remove pixel from currentPixels - for (var j = 0; j < currentPixels.length; j++) { - if (currentPixels[j].x == x && currentPixels[j].y == y) { - currentPixels.splice(j, 1); - break; - } - } - } - } - } -}) - -window.addEventListener("beforeunload",function(){ - clearAll(); - saveSettings(); -}); \ No newline at end of file From bf7d65b46aa3ce9266ae9ee4e6403408ffb68856 Mon Sep 17 00:00:00 2001 From: slweeb <91897291+slweeb@users.noreply.github.com> Date: Mon, 15 Apr 2024 21:06:13 -0400 Subject: [PATCH 08/12] Update mod-list.html --- mod-list.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod-list.html b/mod-list.html index 1cc72a2a..64026e8a 100644 --- a/mod-list.html +++ b/mod-list.html @@ -199,7 +199,7 @@ note_block.jsAdds musical Note BlocksAlice nousersthings.jsDestroyable machines, pipe variants, filters, and morenousernamefound portal.jsAdds portals that can teleport pixelsAlice -pushers.jsAdds pixels that pull pixels towards themvoidapex11 +pullers.jsAdds pixels that pull pixels towards themvoidapex11 pushers.jsAdds pixels that push elements away from themAlice spouts.jsAdds spouts for all liquidskaeud state_voids.jsAdds several elements that each delete a specific state of matter (and combinations thereof)Alice From 9389971e332099e192b0156209e56cccb063a469 Mon Sep 17 00:00:00 2001 From: voidapex11 <154328367+voidapex11@users.noreply.github.com> Date: Tue, 16 Apr 2024 15:46:03 +0100 Subject: [PATCH 09/12] fix bug --- mods/pullers.js | 101 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 100 insertions(+), 1 deletion(-) diff --git a/mods/pullers.js b/mods/pullers.js index 0072128a..70602c4a 100644 --- a/mods/pullers.js +++ b/mods/pullers.js @@ -2,6 +2,11 @@ // a sandboxels mod that adds pullers /* ==CHANGELOG== + Version 1.2.1 +@voidapex11 +~fixed error ++e pullers + Version 1.1.2 @voidapex11 ~fixed spelling mistake's @@ -194,7 +199,7 @@ elements.down_puller = { for (i = 1; i <= pixel.range; i++) { if (!isEmpty(pixel.x, pixel.y - i, true)) { - if (pixelMap[pixel.x][pixel.y - i]['immovable]) {break} + if (pixelMap[pixel.x][pixel.y - i]['immovable']) {break} else { tryMove(pixelMap[pixel.x][pixel.y - i], pixel.x, pixel.y - i + 1); } @@ -252,3 +257,97 @@ elements.up_puller = { if (enabledMods.includes("pushers.js")) { console.log('compatibility with pushers.js and imovable objects coming in a later update of the pullers.js\neventualy...') } + +e_pullerColour='#c3a5d6' + +elements.left_e_puller = { + color: e_pullerColour, + properties: { + range: 10, + pushStrength: 1, + }, + tick: function(pixel) { + if (pixel.charge) { + elements.left_puller.tick(pixel) + } + doDefaults(pixel); + }, + category: "machines", + breakInto: ["metal_scrap", "steel", "iron", "glass", "uranium", "tin"], + tempHigh: 2400, + stateHigh: ["molten_aluminum", "molten_steel", "molten_iron", "molten_glass", "molten_uranium", "molten_tin"], + density: 10000, + hardness: 0.85, + conduct: 1, + state: "solid", +} + + + +elements.right_e_puller = { + color: e_pullerColour, + properties: { + range: 10, + pushStrength: 1, + }, + tick: function(pixel) { + if (pixel.charge) { + elements.right_puller.tick(pixel) + } + + doDefaults(pixel); + }, + category: "machines", + breakInto: ["metal_scrap", "steel", "iron", "glass", "uranium", "tin"], + tempHigh: 2400, + stateHigh: ["molten_aluminum", "molten_steel", "molten_iron", "molten_glass", "molten_uranium", "molten_tin"], + density: 10000, + hardness: 0.85, + conduct: 1, + state: "solid", +} + +elements.down_e_puller = { + color: e_pullerColour, + properties: { + range: 10, + pushStrength: 1, + }, + tick: function(pixel) { + if (pixel.charge) { + elements.down_puller.tick(pixel) + } + + doDefaults(pixel); + }, + category: "machines", + breakInto: ["metal_scrap", "steel", "iron", "glass", "uranium", "tin"], + tempHigh: 2400, + stateHigh: ["molten_aluminum", "molten_steel", "molten_iron", "molten_glass", "molten_uranium", "molten_tin"], + density: 10000, + hardness: 0.85, + conduct: 1, + state: "solid", +} + +elements.up_e_puller = { + color: e_pullerColour, + properties: { + range: 10, + pushStrength: 1, + }, + tick: function(pixel) { + if (pixel.charge) { + elements.up_puller.tick(pixel) + } + doDefaults(pixel); + }, + category: "machines", + breakInto: ["metal_scrap", "steel", "iron", "glass", "uranium", "tin"], + tempHigh: 2400, + stateHigh: ["molten_aluminum", "molten_steel", "molten_iron", "molten_glass", "molten_uranium", "molten_tin"], + density: 10000, + hardness: 0.85, + conduct: 1, + state: "solid", +} \ No newline at end of file From 6e25db878314133159cd568c1baebcf14aa70fd3 Mon Sep 17 00:00:00 2001 From: GuyWhoGotSpringlocked <163777207+GWhoGS@users.noreply.github.com> Date: Tue, 16 Apr 2024 20:00:57 -0400 Subject: [PATCH 10/12] Purple Guy's Mod vFinal Final update of purple guy's mod because i want to make purple guys mod + now --- mods/purple_guys_mod.js | 375 +++++++++++++++++++++++++++++++++------- 1 file changed, 311 insertions(+), 64 deletions(-) diff --git a/mods/purple_guys_mod.js b/mods/purple_guys_mod.js index b0984694..f0d2e53e 100644 --- a/mods/purple_guys_mod.js +++ b/mods/purple_guys_mod.js @@ -591,7 +591,7 @@ elements.r_gullibullium_gas = { elements.boba_pearls = { color: "#3b0a57", behavior: behaviors.POWDER, - category: "Purple Guy's Boba", + category: "Boba", state: "solid", density: 54678900, hardness:0.95 @@ -600,7 +600,7 @@ elements.boba_pearls = { elements.vanilla_boba = { color: "#fff0dd", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -609,7 +609,7 @@ elements.vanilla_boba = { elements.mango_boba = { color: "#ffc77d", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -618,7 +618,7 @@ elements.mango_boba = { elements.matcha_boba = { color: "#58d168", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -627,7 +627,7 @@ elements.matcha_boba = { elements.banana_boba = { color: "#ffe1a1", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -636,7 +636,7 @@ elements.banana_boba = { elements.banana_cream_boba = { color: "#ffffc1", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -645,7 +645,7 @@ elements.banana_cream_boba = { elements.satans_boba = { color: "#852d2d", behavior: behaviors.MOLTEN, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25, @@ -655,7 +655,7 @@ elements.satans_boba = { elements.peach_boba = { color: "#ffbe73", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -664,7 +664,7 @@ elements.peach_boba = { elements.strawberry_boba = { color: "#e27c7c", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -673,7 +673,7 @@ elements.strawberry_boba = { elements.mint_boba = { color: "#8cff9b", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -682,7 +682,7 @@ elements.mint_boba = { elements.mint_vanilla_boba = { color: "#c8ffcf", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -691,7 +691,7 @@ elements.mint_vanilla_boba = { elements.classic_boba = { color: "#ffffff", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -700,7 +700,7 @@ elements.classic_boba = { elements.taro_boba = { color: "#f1c8ff", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -709,7 +709,7 @@ elements.taro_boba = { elements.thai_tea_boba = { color: "#ffc98c", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -718,7 +718,7 @@ elements.thai_tea_boba = { elements.jasmine_green_tea_boba = { color: "#d8ffc7", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -727,7 +727,7 @@ elements.jasmine_green_tea_boba = { elements.honeydew_boba = { color: "#9eff98", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -736,7 +736,7 @@ elements.honeydew_boba = { elements.rose_boba = { color: "#ffe6e6", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -745,7 +745,7 @@ elements.rose_boba = { elements.lavender_boba = { color: "#efbfff", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -754,7 +754,7 @@ elements.lavender_boba = { elements.lychee_boba = { color: "#fff1bf", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -763,7 +763,7 @@ elements.lychee_boba = { elements.passion_fruit_boba = { color: "#ffb942", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -772,7 +772,7 @@ elements.passion_fruit_boba = { elements.pineapple_boba = { color: "#ffe742", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -781,7 +781,7 @@ elements.pineapple_boba = { elements.blueberry_boba = { color: "#272a98", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -790,7 +790,7 @@ elements.blueberry_boba = { elements.raspberry_boba = { color: "#ff3333", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -799,7 +799,7 @@ elements.raspberry_boba = { elements.coconut_boba = { color: "#f1f1f1", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -808,7 +808,7 @@ elements.coconut_boba = { elements.almond_boba = { color: "#e4daa9", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -817,7 +817,7 @@ elements.almond_boba = { elements.hazelnut_boba = { color: "#fbf4d4", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -826,7 +826,7 @@ elements.hazelnut_boba = { elements.caramel_boba = { color: "#e4ab32", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -835,7 +835,7 @@ elements.caramel_boba = { elements.chocolate_boba = { color: "#6f4b00", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -844,7 +844,7 @@ elements.chocolate_boba = { elements.coffee_boba = { color: "#866625", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -853,7 +853,7 @@ elements.coffee_boba = { elements.guava_boba = { color: "#ff390a", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -862,7 +862,7 @@ elements.guava_boba = { elements.kiwi_boba = { color: "#09de0f", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -871,7 +871,7 @@ elements.kiwi_boba = { elements.papaya_boba = { color: "#c4ce37", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -880,7 +880,7 @@ elements.papaya_boba = { elements.black_sesame_boba = { color: "#6e89a9", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -889,7 +889,7 @@ elements.black_sesame_boba = { elements.pandan_boba = { color: "#33d460", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -898,7 +898,7 @@ elements.pandan_boba = { elements.pomegranate_boba = { color: "#ca0000", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -907,7 +907,7 @@ elements.pomegranate_boba = { elements.watermelon_boba = { color: "#f26565", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -916,7 +916,7 @@ elements.watermelon_boba = { elements.grapefruit_boba = { color: "#f1962f", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -925,7 +925,7 @@ elements.grapefruit_boba = { elements.plum_boba = { color: "#dacfd9", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -934,7 +934,7 @@ elements.plum_boba = { elements.jackfruit_boba = { color: "#daa128", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -943,7 +943,7 @@ elements.jackfruit_boba = { elements.soursop_boba = { color: "#ded3bb", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -952,7 +952,7 @@ elements.soursop_boba = { elements.cranberry_boba = { color: "#f81e1e", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -961,7 +961,7 @@ elements.cranberry_boba = { elements.blood_orange_boba = { color: "#ed2115", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -970,7 +970,7 @@ elements.blood_orange_boba = { elements.lemonade_boba = { color: "#ffe151", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -979,7 +979,7 @@ elements.lemonade_boba = { elements.guanabana_boba = { color: "#f5f5f5", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -988,7 +988,7 @@ elements.guanabana_boba = { elements.cherry_blossom_boba = { color: "#f598e8", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -997,7 +997,7 @@ elements.cherry_blossom_boba = { elements.cardamom_boba = { color: "#dac370", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -1006,7 +1006,7 @@ elements.cardamom_boba = { elements.saffron_boba = { color: "#ffe323", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -1015,7 +1015,7 @@ elements.saffron_boba = { elements.pistachio_boba = { color: "#9cff90", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -1024,7 +1024,7 @@ elements.pistachio_boba = { elements.blue_raspberry_boba = { color: "#29c9f1", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -1033,7 +1033,7 @@ elements.blue_raspberry_boba = { elements.cotton_candy_boba = { color: "#f1cfde", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -1042,7 +1042,7 @@ elements.cotton_candy_boba = { elements.bubblegum_boba = { color: "#ff97bc", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -1051,7 +1051,7 @@ elements.bubblegum_boba = { elements.peppermint_boba = { color: ["#ffeff5", "#ff0000"], behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -1060,7 +1060,7 @@ elements.peppermint_boba = { elements.spearmint_boba = { color: ["#ffeff5", "#00ff00"], behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -1085,7 +1085,61 @@ elements.strawberry_kiwi_boba = { "k": "#09de0f" }, behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", + state: "liquid", + density: 1300, + hardness:0.25 +} + +elements.lychee_rose_boba = { + color: "#e04b8c", + behavior: behaviors.LIQUID, + category: "Boba", + state: "liquid", + density: 1300, + hardness:0.25 +} + +elements.raspberry_lemonade_boba = { + color: "#e0604a", + behavior: behaviors.LIQUID, + category: "Boba", + state: "liquid", + density: 1300, + hardness:0.25 +} + +elements.blackberry_boba = { + color: "#232048", + behavior: behaviors.LIQUID, + category: "Boba", + state: "liquid", + density: 1300, + hardness:0.25 +} + +elements.elderflower_boba = { + color: "#ef9d5c", + behavior: behaviors.LIQUID, + category: "Boba", + state: "liquid", + density: 1300, + hardness:0.25 +} + +elements.hibiscus_boba = { + color: "#e8a1cd", + behavior: behaviors.LIQUID, + category: "Boba", + state: "liquid", + density: 1300, + hardness:0.25 +} + +elements.dragon_fruit_boba = { + color: "#cd4747", + behavior: behaviors.LIQUID, + category: "Boba", state: "liquid", density: 1300, hardness:0.25 @@ -1098,7 +1152,7 @@ elements.wasters_personal_boba = { "M2|M1|M2", "M2|XX|M2" ], - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1500, hardness:0.25 @@ -1111,7 +1165,7 @@ elements.when_yous_personal_boba = { "M2|M1|M2", "M2|XX|M2" ], - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 1600, hardness:0.25 @@ -1120,16 +1174,16 @@ elements.when_yous_personal_boba = { elements.nousernamefounds_gallium_boba = { color: ["#b1b1b1", "#bfbfbf", "#9e9e9e"], behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 5100, hardness:0.25 } -elements.bartender_twix_hartwell_whites_bday_cake_boba = { +elements.bart_ender_twixs_birthday_cake_boba = { color: "#e6dbe4", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 2000, hardness:0.25 @@ -1138,7 +1192,7 @@ elements.bartender_twix_hartwell_whites_bday_cake_boba = { elements.sb_boba = { color: ["#000000", "#ffff00", "#3a3a3a", "#ff0000"], behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 2000, hardness:0.25 @@ -1147,7 +1201,7 @@ elements.sb_boba = { elements.sethies_red_boba = { color: "#ff8282", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 2000, hardness:0.25 @@ -1156,7 +1210,7 @@ elements.sethies_red_boba = { elements.sethies_blue_boba = { color: "#82c0ff", behavior: behaviors.LIQUID, - category: "Purple Guy's Boba", + category: "Boba", state: "liquid", density: 2010, hardness:0.25 @@ -1516,8 +1570,8 @@ elements.water_but_it_stays_liquid = { elements.blue_uranium = { color: ["#4ba5ff","#71a8de","#b4c7da","#3e6892","#6da4da","#9dc1e6"], behavior: [ - "XX|CR:radiation%20|XX", - "CR:radiation%1|CH:lead%0.001|CR:radiation%20", + "XX|CR:radiation%15|XX", + "CR:radiation%1|CH:lead%0.001|CR:radiation%15", "M2|M1|M2", ], reactions: { @@ -3298,6 +3352,186 @@ elements.turtle_egg = { breakInto: "crushed_shell" } +elements.radium = { + color: ["#d9d9d9", "#d0d0d0", "#b3b3b3"], + behavior: [ + "XX|CR:radiation%1000000|XX", + "CR:radiation%1000000|CH:lead%0.001|CR:radiation%1000000", + "M2|M1|M2", + ], + reactions: { + "neutron": { elem1:"n_explosion", tempMin:700, chance:0.1 } + }, + tempHigh: 1132.2, + category: "powders", + state: "solid", + density: 5500, + hardness: 0.45, + conduct: 0.235, + excludeRandom: true +} + +elements.unbreakable_battery = { + color: "#9d8725", + behavior: [ + "XX|SH|XX", + "SH|XX|SH", + "XX|SH|XX", + ], + category: "machines", + hardness: 1 +} + +elements.diamond_wall = { + color: ["#03fcec","#03c6fc","#b3eeff","#8ab0e6"], + behavior: behaviors.WALL, + category: "solids", + tempHigh: 900, + stateHigh: "carbon_dioxide", + state: "solid", + density: 3515, + hardness: 0.99, + breakInto: "diamond" +} + +elements.osmium = { + color: ["#bddee4","#a7c3c8","#98b3b7"], + behavior: behaviors.WALL, + category: "solids", + tempHigh: 3033, + state: "solid", + density: 3515, + hardness: 0.7, + breakInto: "osmium_shard" +} + +elements.osmium_shard = { + color: ["#bddee4","#a7c3c8","#98b3b7"], + behavior: behaviors.POWDER, + category: "powders", + tempHigh: 3033, + state: "solid", + density: 3515, + hardness: 0.7, +} + +elements.copper_scrap = { + color: ["#a95232","#be4322","#c76035"], + behavior: behaviors.POWDER, + reactions: { + "blood": { elem1:"oxidized_copper_scrap", chance:0.003 }, + "infection": { elem1:"oxidized_copper_scrap", chance:0.003 }, + "antibody": { elem1:"oxidized_copper_scrap", chance:0.003 }, + "fire": { elem1:"oxidized_copper_scrap", chance:0.0025 }, + }, + category: "powders", + tempHigh: 1085, + density: 8960, + conduct: 0.95, + hardness: 0.3, + fireColor: ["#07BA4F","#00BC5B","#00C2A9","#11B7E7","#C6F2EC"] +} + +elements.oxidized_copper_scrap = { + color: ["#406555","#42564a","#517364"], + behavior: behaviors.POWDER, + reactions: { + "hydrogen": {tempMin:900, elem1:"copper_scrap", elem2:"steam"} + }, + category: "powders", + hidden: true, + tempHigh: 1085, + stateHigh: "molten_copper", + density: 8960, + conduct: 0.85, + hardness: 0.2, + alias: "copper carbonate" +} + +elements.cleaning_solution = { + color: "#5894e9", + behavior: behaviors.LIQUID, + reactions: { + "milk": { elem1: null, elem2: "cheese" }, + "pilk": { elem1: null, elem2: "cheese", color2:"#c48a25" }, + "fruit_milk": { elem1: null, elem2: "cheese", color2:"#c2864e" }, + "chocolate_milk": { elem1: null, elem2: "cheese", color2:"#6b4000" }, + "eggnog": { elem1: null, elem2: "cheese", color2:"#ffdb63" }, + "nut_milk": { elem1: null, elem2: "cheese", color2:"#ded0ad" }, + "yogurt": { elem1: null, elem2: "cheese" }, + "baking_soda": { elem1: "sodium_acetate", elem2: "carbon_dioxide", attr1:{"foam":20} }, + "limestone": { elem1: "sodium_acetate", elem2: "carbon_dioxide", attr1:{"foam":5} }, + "rust": { elem2:"iron", chance:0.05 }, + "oxidized_copper": { elem2:"copper", chance:0.05 }, + "egg": { elem2:"yolk", chance:0.0005 }, + "yolk": { elem1:"mayo", elem2:"mayo", chance:0.1 }, + "mushroom_spore": { elem2:null, chance:0.05 }, + "mushroom_gill": { elem2:null, chance:0.05 }, + "mushroom_cap": { elem2:null, chance:0.05 }, + "pollen": { elem2:null, chance:0.05 }, + "salt": { elem1: null, elem2: "sodium_acetate", chance:0.05 }, + "lettuce": { elem2:"pickle", chance:0.01 }, + "egg": { elem2:"pickle", color2:"#e0e0ab", chance:0.01 }, + "tomato": { elem2:"pickle", color2:"#fa6e11", chance:0.01 }, + "grape": { elem2:"pickle", color2:"#b86a4b", chance:0.01 }, + "pumpkin": { elem2:"pickle", color2:"#ffa42e", chance:0.01 }, + "dirt": { elem1: null, elem2: "mud" }, + "sand": { elem1: null, elem2: "wet_sand" }, + "clay_soil": { elem1: null, elem2: "clay" }, + }, + viscosity: 12, + tempHigh: 100.6, + stateHigh: ["steam","carbon_dioxide","methane"], + tempLow: -2.22, + stateLowName: "frozen_cleaning_solution", + category: "liquids", + state: "liquid", + density: 1006, + stain: -1.05 +} + +elements.abs_zero = { + color: "#a2ddff", + tool: function(pixel) { + pixel.temp = absoluteZero + pixelTempCheck(pixel); + }, + category: "tools", + excludeRandom: true +} + +elements.firedoesntwork = { + color: "#c44f45", + tick: function(pixel) { + if ((pixel.temp > absoluteZero || pixel.charge) && !pixel.burning) { + pixel.burning = true; + pixel.burnStart = pixelTicks; + } + if (pixel.burning) { + if (!tryMove(pixel, pixel.x, pixel.y-1)) { + // tryMove again to the top left or top right + tryMove(pixel, pixel.x+(Math.random() < 0.5 ? -1 : 1), pixel.y-1); + } + if (pixelTicks-pixel.burnStart > 50 && Math.random() < 0.1) { + explodeAt(pixel.x, pixel.y, 10, "fw_ember"); + } + } + else { + if (!tryMove(pixel, pixel.x, pixel.y+1)) { + // tryMove again to the bottom left or bottom right + tryMove(pixel, pixel.x+(Math.random() < 0.5 ? -1 : 1), pixel.y+1); + } + } + doDefaults(pixel); + }, + burn: 90, + burnTime: 100, + density: 2000, + conduct: 1, + state: "solid", + category: "weapons" +} + if (!elements.sand.reactions) { elements.sand.reactions = {} } elements.sand.reactions.dirt = { elem1:"dirty_sand", elem2:"dirty_sand" } @@ -3374,6 +3608,9 @@ elements.when_iium.reactions.when_i_particles = { elem1:"when_i_particles", elem if (!elements.ash.reactions) { elements.ash.reactions = {} } elements.ash.reactions.dust = { elem1:"dusty_ash", elem2:"dusty_ash" } +if (!elements.vinegar.reactions) { elements.vinegar.reactions = {} } +elements.vinegar.reactions.alchohol = { elem1:"cleaning_solution", elem2:"cleaning_solution" } + elements.steel.hardness = 0.85 elements.uncharge.category = "tools" @@ -3384,5 +3621,15 @@ elements.room_temp.category = "tools" elements.heat_ray.category = "rays" +elements.battery.breakInto = "explosion" + +elements.oxidized_copper.category = "solids" + +elements.oxidized_copper.behavior = behaviors.SOLID + +elements.oxidized_copper.breakInto = "oxidized_copper_scrap" + +elements.body.color = ["#069469","#047e99","#7f5fb0", "#e85858", "#e8ac58", "#e8cc47", "#48e84e", "#48e7e8", "#488be8", "#9312e8", "#e8136e", "#8e492d"] + // important colors: ["#000000", "#edff00", "#3a3a3a", "#ff0000"], ["#82c0ff", "#ff8282"], ["#cca77c","#ad8b63","#b59d81","#c7a073","#c9b297"], \ No newline at end of file From 5c9ce253c6d2d4e00dfa8e24d497c52a14e9b5b4 Mon Sep 17 00:00:00 2001 From: Retorta1 <165048795+Retorta1@users.noreply.github.com> Date: Wed, 17 Apr 2024 21:21:00 +0200 Subject: [PATCH 11/12] Update hu.json Added translation for sandstorm and fixed a typo --- lang/hu.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lang/hu.json b/lang/hu.json index a771c0f6..b8645d87 100644 --- a/lang/hu.json +++ b/lang/hu.json @@ -348,7 +348,7 @@ "amber":"borostyán", "caramel":"karamella", "molasses":"melasz", -"ketchup":"kechup", +"ketchup":"ketchup", "mayo":"majonéz", "melted_chocolate":"olvasztott_csokoládé", "liquid_hydrogen":"folyékony_hidrogén", @@ -475,8 +475,8 @@ "molten_dirt":"olvadt_föld", "debug":"hibaelhárító", "prop":"tulajdonság-állító", -"salt_ice":"só_jég", -"sugar_ice":"cukor_jég", +"salt_ice":"sós_jég", +"sugar_ice":"cukros_jég", "seltzer_ice":"fagyott_szódavíz", "dirty_ice":"piszkos_jég", "pool_ice":"fagyott_medencevíz", @@ -531,7 +531,7 @@ "molten_potassium": "olvadt_kálium", "magnesium": "magnézium", "molten_magnesium": "olvadt_magnézium", -"sandstorm": "", +"sandstorm": "homokvihar", "caustic_potash": "kálium-hidroxid", "antibomb": "antibomba", "tornado": "tornádó", From cb4d253b2927b796bd6bdacf3981819c83c2df2f Mon Sep 17 00:00:00 2001 From: CarbonMonoxida <164758530+CarbonMonoxida@users.noreply.github.com> Date: Thu, 18 Apr 2024 17:13:50 +0700 Subject: [PATCH 12/12] Update aScientistsWish.js Changelog: 1. Update for rad rock 2. Add rad cleaner 3. Add rad snow --- mods/aScientistsWish.js | 73 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/mods/aScientistsWish.js b/mods/aScientistsWish.js index 90e306de..88a3ca54 100644 --- a/mods/aScientistsWish.js +++ b/mods/aScientistsWish.js @@ -29,6 +29,7 @@ elements.liquid_carbon_monoxide = { category: "liquids", state: "liquid", density: 1.14, + darkText: true, tempHigh: -190, temp: -192, tempLow: -199, @@ -44,6 +45,7 @@ elements.ice_carbon_monoxide = { temp: -199, density: 1.14, tempHigh: -192, + darkText: true, stateHigh: "liquid_carbon_monoxide", }; elements.carbon_monoxide_detector = { @@ -189,6 +191,8 @@ elements.fallout_drum = { state: "solid", density: 9000, color: "#e3cc34", + tempHigh: 2500, + stateHigh: ["aluminum","radiated_water","radiated_water","fallout"], breakInto: ["fallout","fallout"], reactions: { "water": { elem1:"fallout_drum", elem2:"radiated_water" }, @@ -226,9 +230,13 @@ elements.polluted_air = { "head": { elem2:"rotten_meat" }, "human": { elem2:"rotten_meat" }, "bird": { elem2:"rotten_meat" }, - "cell": { elem2:"cancer"}, + "cell": { elem2:"cancer" }, "water": { elem1: null, elem2: "radiated_water" }, - } + "worm": { elem2: ["ash","cancer"] }, + "flea": { elem2: "ash" }, + "seed": {elem2: "dead_plant" }, + "plant": {elem1: null, chance:0.5, elem2: "dead_plant", chance:0.5 }, + }, }; elements.siren = { @@ -267,4 +275,65 @@ elements.rad_ice = { color: ["#81d79c","#68b899","#68abb8"], hidden: true, temp: -6, + tempHigh: 5, + stateHigh: ["radiated_water","water"], + reactions: { + "snow": { elem2:"dirty_water" }, + "water": { elem2:"radiated_water" }, + } +} + +elements.rad_snow = { + behavior: behaviors.POWDER, + category: "radiated", + state:"powder", + density: 1500, + color: ["#9effe4","#b5fffd","#d4fff1"], + temp: -2, + tempHigh: 21, + stateHigh: "radiated_water", +}; + +elements.rad_rock = { + behavior: behaviors.POWDER, + category: "land", + state: "powder", + density: 2790, + color: ["#34382d","#3f4633","#595a4d"], + tempHigh: 1200, + stateHigh: ["magma","fallout"], + reactions: { + "water": { elem2:"dirty_water" }, + "salt_water": { elem2:"dirty_water" }, + "sugar_water": { elem2:"dirty_water" }, + "seltzer": { elem2:"dirty_water" }, + "bleach": {elem2: "rock", chance:0.1 }, + "rad_cleaner": { elem1:"rock" }, + "foam": { elem1:"rock" }, + "juice": { elem2: null }, + "blood": { elem2:"infection" }, + "grass": { elem2:"dead_plant" }, + "plant": { elem2:"dead_plant" }, + "cell": { elem2:"cancer" }, + "worm": { elem2:"ash" }, + "glass": { elem2:"rad_glass"}, + "glass_shard": { elem2:"rad_shard" }, + } +}; + +elements.rad_cleaner = { + behavior: behaviors.WALL, + category: "machines", + state: "solid", + density: 2500, + color: ["#383838","#212220"], + desc: "clean radiated elements", + tempHigh: 1250, + stateHigh: ["fallout","molten_plastic","steam"], + reactions: { + "radiated_water": {elem2:"water" }, + "polluted_air": {elem2: "oxygen"}, + "rad_snow": {elem2: "snow"}, + "rad_rock": {elem2: "rock"}, + } }