This commit is contained in:
JustAGenericUsername 2024-04-15 20:59:45 -04:00
commit 60a93c6e94
13 changed files with 5319 additions and 784 deletions

View File

@ -137,6 +137,7 @@
<tr><td>find.js</td><td>Adds a find mode that highlights a chosen element as pulsating red and yellow <a href="https://github.com/R74nCom/sandboxels/commit/de0dc088ab4d928c77587b9d0e3a7d7663e3f94a">(read commit description)</a></td><td>Alice</td></tr>
<tr><td>insane_random_events.js</td><td>Massively buffs random events</td><td>Alice</td></tr>
<tr><td>invertscroll.js</td><td>Inverts the scroll wheel for adjusting brush size</td><td>SquareScreamYT</td></tr>
<tr><td>mobile_shift.js</td><td>Adds a button for shift on mobile</td><td>SquareScreamYT</td></tr>
<tr><td>moretools.js</td><td>Adds more temperature-modifying tools (±10/tick, ±50/tick, and absolute zero tools)</td><td>Sightnado</td></tr>
<tr><td>move_tools.js</td><td>Adds tools that move pixels</td><td>Alice</td></tr>
<tr><td>noconfirm.js</td><td>Removes all confirmation pop ups</td><td>mollthecoder</td></tr>
@ -220,7 +221,9 @@
<!----><tr><td class="modCat" colspan="3">Food & Cooking</td></tr><!---->
<tr><td>aChefsDream.js</td><td>Adds more foods, animals, tools and many other cooking related items. Updates can be found in <a href="https://www.youtube.com/watch?v=pQFTtlNPODQ&list=PLWHqGb75vC8o7CLv-pMoVb56JL9BY9F0t">this YouTube Playlist</a></td><td>SquareScreamYT</td></tr>
<tr><td>aChefsDream_beta.js</td><td>Beta testing for aChefsDream. The code can be found <a href="https://www.github.com/SquareScreamYT/aChefsDream.js">on GitHub</a></td><td>SquareScreamYT</td></tr>
<tr><td>bananas.js</td><td>Adds bananas and banana plants</td><td>Alice</td></tr>
<tr><td>community_desserts.js</td><td>Adds various desserts from community suggestions</td><td>Tisquares</td></tr>
<tr><td>greenitemsandmore.js</td><td>Adds various green things, including apples and more food</td><td>zonneschijn7</td>
<tr><td>ketchup_mod.js</td><td>Adds a bunch of ketchup related stuff, plus a few other condiments</td><td>Nubo318 (main dev), Devi, Alice (contributors)</td></tr>
<tr><td>lemonade.js</td><td>Adds lemons and lemonade</td><td>personman / baconthemyth</td></tr>

89
mods/Batteries.js Normal file
View File

@ -0,0 +1,89 @@
elements.charged_battery= {
color: "#9c6c25",
behavior: [
"XX|SH%50|XX", // shocks (adds charge)
"SH%50|CH:low_battery%0.05|SH%50",
"XX|SH%50|XX",
],
colorOn: "#00ff00",
category: "machines",
tempHigh: 1455.5,
stateHigh: ["molten_steel","explosion","acid_gas"],
charge: 0.5,
conduct: 1,
};
elements.low_battery= {
color: "#9c6c25",
behavior: [
"XX|SH%10|XX", // shocks (adds charge)
"SH%10|CH:dead_battery%0.05|SH%10",
"XX|SH%10|XX",
],
colorOn: "#4fb613",
category: "machines",
tempHigh: 1455.5,
stateHigh: ["molten_steel","explosion","acid_gas"],
charge: 0.5,
conduct: 0.75,
};
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",
],
colorOn: "#699e19",
category: "machines",
tempHigh: 1455.5,
stateHigh: ["molten_steel","explosion","acid_gas"],
charge: 0.5,
conduct: 0.5,
};
elements.radio_broadcaster= {
color: "#78784c",
behavior: behaviors.WALL,
behaviorOn: [
"XX|SH AND CR:radio_wave AND CR:radio_wave|XX",
"SH AND CR:radio_wave AND CR:radio_wave|XX|SH AND CR:radio_wave AND CR:radio_wave",
"XX|SH AND CR:radio_wave AND CR:radio_wave|XX",
],
colorOn: "#ffff59",
category: "machines",
tempHigh: 1455.5,
stateHigh: ["molten_steel","explosion","acid_gas"],
conduct: 1
};
elements.radio_receiver= {
color: "#78784c",
behavior: behaviors.WALL,
reactions: {radio_wave: {elem2: "electric", chance: 0.75}},
colorOn: "#ffff59",
category: "machines",
tempHigh: 1455.5,
stateHigh: ["molten_steel","explosion","acid_gas"],
conduct: 1
};
elements.radio_wave= {
color: ["#000000"],
behavior: behaviors.BOUNCY,
behaviorOn: [
["XX","CL","XX"],
["CL","DL%5","CL"],
["XX","CL","XX"]
]
,
colorOn: "#000000",
tick: function(pixel){
if (currentElement == "radio_wave"){
pixel.color = "rgb(15, 15, 15)";
} else {
pixel.color = "rgba(0, 0, 0, -1)";
}
},
category: "energy",
density: 1,
//charge: 0.5,
conduct: 0.01
};

View File

@ -1,6 +1,6 @@
// Science mod for Sandboxels
// (Inspired by survival.js)
// Build 11
// Build 17
// By: Lucifer (@a_british_proto (Discord))
// If there is anything you want to suggest or there's a bug then just dm me on discord
// Todo:
@ -19,6 +19,7 @@ if (!settings.Science_mod) {
"Beryllium": 9.223372036854776e+18,
"Boron": 9.223372036854776e+18,
"Carbon": 9.223372036854776e+18,
"Nitrogen": 9.223372036854776e+18,
"Oxygen": 9.223372036854776e+18,
"Flourine": 9.223372036854776e+18,
"Neon": 9.223372036854776e+18,
@ -1086,52 +1087,303 @@ element.Oganesson = {
// Substance proporties (These are the properties of the substances, not the elements These properties
// use hidden:true as you don't start with these but instead have to craft them):
substance.Polystyrene = {
behavior: behaviors.WALL,
color:"FFFFFF",
category:"land",
// I replaced all of it with this because it might get in the way in future updates
substance.Silver_Hexafluoroarsenate = {
behavior: behaviours.WALL,
color:"FFFFFE",
category:"lands",
state:"solid",
hidden:true
}
substance.Styrene = {
substance.Silver_Tetrafluoroborate = {
behavior: behaviors.POWDER,
color: "FAF9F6",
category: "lands",
state: "powder",
hidden:true
}
substance.Silver_Bromide = {
behavior: behaviors.WALL,
color: "FDFD96",
category: "lands",
state: "solid",
hidden: true
}
substance.Silver_Bromate = {
behavior: behaviors.POWDER,
colour: "FFFFFF",
category: "lands",
state: "powder",
hidden:true
}
substance.Silver_Picrate_Monohydrate = {
behavior: behaviors.WALL,
color: "E4D99F",
category: "lands",
state: "solid",
hidden:true
}
substance.Silver_Chloride = {
behavior: behaviors.WALL,
color: "FFFFFF",
category: "lands",
state: "solid",
hidden:true
}
substance.Silver_Perchlorate_Hydrate = {
behavior: behaviors.WALL,
color: "FFFFFF",
category: "lands",
state: "solid",
hidden:true
}
// I can't believe i almost forgor about the "."
subtance.Silver_Perchlorate_Monohydrate = {
behavior: behaviors.POWDER,
color: "FFFFFF",
category: "lands",
state: "powder",
hidden:true
}
substance.Silver_Chlorite = {
behavior: behaviors.WALL,
colour: "FFFF00",
category: "lands",
state: "solid",
hidden:true
}
substance.Silver_Chlorate ={
behavior: behaviors.WALL,
color: "FFFFFF",
category: "lands",
state: "solid",
hidden:true
}
substance.Silver_Perchlorate = {
behavior: behaviors.WALL,
color: "FFFFFF",
category: "lands",
state: "solid",
hidden:true
}
substance.Silver_Fluoride = {
behavior: behaviors.WALL,
color: "9B7A01",
category: "lands",
state: "solid",
hidden:true
}
// Basically the same as Silver_Floride but instead the second version
subtance.Silver_Difluoride = {
behavior: behaviors.WALL,
color: "9B7A01",
category: "lands",
state: "solid",
hidden:true
}
// Only just realised that this had spaces :skull:
substance.Silver_Hydrogen_Sluoride = {
// I'm guessing that this is a liquid
behavior: behaviors.LIQUID,
color:"FFFFED",
category:"liquids",
state:"liquid",
color: "FFFFFF",
category: "liquid",
state: "liquid",
hidden:true
}
substance.Cinnamaldehyde = {
behavior: behaviors.LIQUID,
color:"FDFD96",
category:"liquids",
state:"liquid",
// Why are a bunch of these just silver compounds? Really weird :/
subtance.Silver_Hexafluorophosphate = {
behavior: behaviors.POWDER,
color: "FFFFFF",
category: "lands",
state: "powder",
hidden:true
}
substance.Acetone = {
behavior: behaviors.LIQUID,
color:"DADEDF",
category:"liquids",
state:"liquid",
substance.Silver_Hexafluoroantimonate = {
behavior: behaviors.WALL,
color: "FFFDD0",
category: "lands",
state: "solid",
hidden:true
}
substance.Methane = {
behavior: behaviors.GAS,
color:"C1C7C9",
category:"gases",
state:"gas",
// There's a purple crystal version and a brown powder version
// Why does this sound like something you'd get at a posh (maybe Italian) restruant (without the "01" and the "_")
subtance.Silver_permanganate_01 = {
behavior: behaviours.WALL,
color: "800080",
category: "lands",
state: "solid",
hidden:true
}
substance.Ethane = {
behavior: behaviors.GAS,
color:"C1C7C9",
category:"gases",
state:"gas",
subtance.Silver_permanganate_02 = {
behavior: behaviors.POWDER,
color: "964B00",
category: "lands",
state: "powder",
hidden:true
}
// Doing more tmrw
substance.Silver_Vandium_Trioxide = {
behavior: behaviors.WALL,
color: "FFFF00",
category: "lands",
state: "solid",
hidden:true
}
// Why is this fun? How is this not torture? This is line 1247! (at the time I am making this comment)
// I think there's two silver iodides I'm just not so sure (and I ain't editing this after)
// Nvm it's only one , I got silver iodide and silver iodate mixed up :skull:
subtance.Silver_Iodide = {
behavior: behaviors.POWDER,
color: "E4D99F",
category: "lands",
state: "powder",
hidden:true
}
substance.Silver_Iodate = {
behavior: behaviors.WALL,
color: "FFFFFF",
category: "lands",
state: "solid",
hidden: true
}
// I was confused at first on why there were two silver nitrates, but now I understand
substance.Silver_Nitrate_01 = {
behavior: behaviors.WALL,
color: "FFFFFF",
category: "lands",
state: "solid",
hidden:true
}
substance.Silver_Nitrate_02 = {
behavior: behaviors.POWDER,
color: "FFFFFF",
category: "lands",
state: "powder",
hidden:true
}
subtance.Silver_Azide = {
behavior: behaviors.WALL,
color: "FFFFFF",
category: "lands",
state: "solid",
hidden:true
}
// This one is powder and crystals
substance.Silver_Oxzide_01 = {
behavior: behaviors.POWDER,
color: "000001",
category: "lands",
state: "powder",
hidden:true
}
substance.Silver_Oxzide_02 = {
behavior: behaviors.WALL,
color: "000001",
category: "lands",
state: "solid",
hidden:true
}
substance.Silver_Metaphospahte = {
behavior: behaviors.WALL,
color: "FFFF00",
category: "lands",
state: "solid",
hidden:true
}
substance.Silver_Perrhenate = {
behavior: behaviors.WALL,
color: "FFFFFF",
category: "lands",
state: "solid",
hidden:true
}
substance.Silver_Acetylide = {
behavior: behaviors.WALL,
color: "C0C0C0",
category: "lands",
state: "solid",
hidden:true
}
substance.Silver_Chromate = {
behavior: behaviors.POWDER,
color: "A52A2A",
category: "lands",
state: "powder",
hidden:true
}
substance.Silver_Dichromate = {
behavior: behaviors.WALL,
color: "A52A2A",
category: "lands",
state: "solid",
hidden:true
}
substance.Silver_Subfluoride = {
behavior: behaviors.WALL,
color: "CD7F32",
category: "lands",
state: "solid",
hidden:true
}
substance.Silver_Sulfide = {
behavior: behaviors.WALL,
color: "3f3f3f",
category: "lands",
state: "solid",
hidden:true
}
substance.Silver_Oxzide = {
behavior: behaviors.POWDER,
color: "000002",
category: "lands",
state: "powder",
hidden:true
}
// Editing this later on when I get back home
substance.Silver_Sulfate = {
behavior: behaviors.WALL,
color: "FFFFFF",
category: "lands"
state: "solid",
hidden:true
}
// I done this on my school computers :skull:
// doing more later
// I accidentally pressed Ctrl+V instead of Ctrl+C so it deleted my work D:

View File

@ -15,7 +15,7 @@ elements.rubidium = {
var coord = squareCoords[i];
var x = pixel.x+coord[0];
var y = pixel.y+coord[1];
if(!isEmpty(x, y, true)){
if (!isEmpty(x, y, true)){
var otherPixel = pixelMap[x][y]
if (otherPixel.element == "liquid_ammonia"){foundelem1 = true; break}
}
@ -24,7 +24,7 @@ elements.rubidium = {
var coord = squareCoords[i];
var x = pixel.x+coord[0];
var y = pixel.y+coord[1];
if(!isEmpty(x, y, true)){
if (!isEmpty(x, y, true)){
var otherPixel = pixelMap[x][y]
if (otherPixel.element == "oxygen"){foundelem2 = true; break}
}
@ -122,11 +122,21 @@ elements.radiocesium = {
tempHigh: 29,
stateHigh: "liquid_radiocesium",
density: 1873,
tick: function (pixel) {
if (Math.random()<0.007) {
if (Math.random()<0.5) {
changePixel(pixel, "barium")
}
else {
changePixel(pixel, "radiobarium")
}
}
},
reactions: {
"water": {func: (pixel1) => {pixel1.burning=true;pixel1.burnStart=pixelTicks},
elem1: ["rad_steam", "fallout"], elem2: "explosion"}
}
}
};
elements.liquid_radiocesium = {
color: ["#e8dcc1", "#d4c6a5", "#bfbaae", "#f5f1e9"],
@ -136,21 +146,270 @@ elements.liquid_radiocesium = {
tempLow: 28,
stateLow: "radiocesium",
density: 1842,
tick: function (pixel) {
if (Math.random()<0.007) {
if (Math.random()<0.5) {
changePixel(pixel, "barium")
}
else {
changePixel(pixel, "radiobarium")
}
}
},
reactions: {
"water": {func: (pixel1) => {pixel1.burning=true;pixel1.burnStart=pixelTicks},
elem1: ["rad_steam", "fallout"], elem2: "explosion"}
}
}
};
elements.lithium = {
color: ["#e3a814", "#dbab32", "#e8bc4f", "#fabf2d"],
elements.barium = {
color: ["#1e1e1e", "#353535", "#4e4e4e", "#696969"],
behavior: behaviors.POWDER,
category: "powders",
state: "solid",
fireColor: "#8c21de",
burn: 1,
burnTime: 500,
tempHigh: 29,
stateHigh: "liquid_cesium",
density: 534,
tempHigh: 730,
stateHigh: "liquid_barium",
density: 3510,
reactions: {
"water": {elem1: "barium_hydroxide", elem2: "pop"}
}
};
elements.liquid_barium = {
color: ["#1e1e1e", "#353535", "#4e4e4e", "#696969"],
behavior: behaviors.POWDER,
hidden: true,
state: "liquid",
tempLow: 729,
stateLow: "barium",
density: 3338
}
elements.radiobarium = {
color: ["#1e1e1e", "#353535", "#4e4e4e", "#696969"],
behavior: behaviors.POWDER,
hidden: true,
state: "solid",
density: 3510,
tick: function (pixel) {
if (Math.random()<0.007) {
changePixel(pixel, "barium")
for (var i = 0; i < squareCoords.length; i++) {
var coord = squareCoords[i];
var x = pixel.x+coord[0];
var y = pixel.y+coord[1];
var rays = 0;
if (isEmpty(x, y)){
createPixel("gamma_ray", x, y)
rays += 1
if (rays == 2) {
break
}
}
}
}
}
};
elements.barium_hydroxide = {
color: ["#f4f4f4", "#ffffff", "#ebebeb", "#e5e5e5"],
behavior: behaviors.POWDER,
hidden: true,
state: "solid",
density: 3510
}
elements.gamma_ray = {
color: "#ffffff",
behavior: [
"XX|XX|XX",
"XX|DL%5|XX",
"XX|XX|XX",
],
hidden: true,
temp: 1000,
state: "gas",
density: 0.00001,
ignoreAir: true,
tick: behaviors.BOUNCY
};
elements.lithium = {
color: ["#e8e8e8", "#f5f5f5", "#c9c9c9", "#d4d4d4"],
behavior: behaviors.POWDER,
category: "powders",
state: "solid",
tempHigh: 180.5,
stateHigh: "liquid_lithium",
density: 534,
tick: function (pixel){
var otherPixel;
for (var i = 0; i < squareCoords.length; i++) {
var coord = squareCoords[i];
var x = pixel.x+coord[0];
var y = pixel.y+coord[1];
if (isEmpty(x, y, true)){
if(Math.random()<0.003) {
changePixel(pixel, "dull_lithium")
}
}
if (!isEmpty(x, y, true)) {
otherPixel = pixelMap[x][y];
if (otherPixel.element != "mineral_oil") {
if (otherPixel.element != "lithium" && otherPixel.element != "dull_lithium" && otherPixel.element != "tarnished_lithium") {
if(Math.random()<0.0007) {
changePixel(pixel, "dull_lithium")
}
}
}
}
}
},
reactions: {
"water": {elem1: "lithium_hydroxide", elem2: "hydrogen", temp2: 400},
"hydrogen": {elem1:"lithium_hydride", elem2: null, chance: 0.5}
}
};
elements.dull_lithium = {
color: ["#d4d4d4", "#e3e3e3", "#b3b3b3", "#bfbfbf"],
behavior: behaviors.POWDER,
hidden: true,
state: "solid",
tempHigh: 180.5,
stateHigh: "liquid_lithium",
density: 534,
tick: function (pixel){
var otherPixel;
for (var i = 0; i < squareCoords.length; i++) {
var coord = squareCoords[i];
var x = pixel.x+coord[0];
var y = pixel.y+coord[1];
if (isEmpty(x, y, true)){
if(Math.random()<0.003) {
changePixel(pixel, "dull_lithium")
}
}
if (!isEmpty(x, y, true)) {
otherPixel = pixelMap[x][y];
if (otherPixel.element != "mineral_oil") {
if (otherPixel.element != "lithium" && otherPixel.element != "dull_lithium" && otherPixel.element != "tarnished_lithium") {
if(Math.random()<0.0007) {
changePixel(pixel, "dull_lithium")
}
}
}
}
}
},
reactions: {
"water": {elem1: "lithium_hydroxide", elem2: "hydrogen", temp2: 400},
"hydrogen": {elem1:"lithium_hydride", elem2: null, chance: 0.5}
}
};
elements.tarnished_lithium = {
color: ["#212121", "#303030", "#0d0d0d", "#404040"],
behavior: behaviors.POWDER,
state: "solid",
hidden: true,
tempHigh: 180.5,
stateHigh: "liquid_lithium"
};
elements.liquid_lithium = {
color: ["#e8e8e8", "#f5f5f5", "#c9c9c9", "#d4d4d4"],
behavior: behaviors.LIQUID,
hidden: true,
state: "liquid",
tempLow: 179.5,
stateLow: "lithium",
density: 511.7
};
elements.lithium_hydroxide = {
color: ["#ffffff", "#f1f1f1", "#e7e7e7", "#ededed"],
behavior: behaviors.POWDER,
hidden: true,
state: "solid",
tempHigh: 180.5,
stateHigh: "liquid_lithium",
density: 1540,
};
elements.lithium_hydride = {
color: ["#8a8a8a", "#b5b5b5", "#bbbbbb"],
behavior: behaviors.POWDER,
hidden: true,
state: "solid",
density: 820,
tick: function (pixel){
var otherPixel;
for (var i = 0; i < squareCoords.length; i++) {
var coord = squareCoords[i];
var x = pixel.x+coord[0];
var y = pixel.y+coord[1];
if (isEmpty(x, y, true)){
var chance = Math.random()
if(Math.random()<0.003) {
if (chance<0.3) {
changePixel(pixel, "lithium_hydroxide")
}
else if (chance>0.3 && chance<0.7) {
changePixel(pixel, "lithium_oxide")
}
else {
changePixel(pixel, "lithium_carbonate")
}
}
}
if (!isEmpty(x, y, true)) {
otherPixel = pixelMap[x][y];
if (otherPixel.element != "mineral_oil") {
if (otherPixel.element != "lithium" && otherPixel.element != "dull_lithium" && otherPixel.element != "tarnished_lithium") {
var chance = Math.random()
if(Math.random()<0.0007) {
if (chance<0.3) {
changePixel(pixel, "lithium_hydroxide")
}
else if (chance>0.3 && chance<0.7) {
changePixel(pixel, "lithium_oxide")
}
else {
changePixel(pixel, "lithium_carbonate")
}
}
}
}
}
}
},
};
elements.lithium_oxide = {
color: ["#ffffff", "#ececec", "#dbdbdb"],
behavior: behaviors.POWDER,
hidden: true,
state: "solid",
density: 2013,
reactions: {
"water": {elem1: "lithium_hydroxide", elem2: "pop", chance: 0.2},
"carbon_dioxide": {elem1: "lithium_carbonate", elem2: null}
}
};
elements.lithium_carbonate = {
color: ["#ffffff", "#e0e0e0", "#c9c8c8"],
behavior: behaviors.POWDER,
hidden: true,
state: "solid",
density: 2110
};
elements.mineral_oil = {
color: ["#cdf6fa", "#e6fdff", "#bff9ff", "#f5feff"],
behavior: behaviors.LIQUID,
state: "liquid",
category: "liquids",
density: 870,
};

View File

@ -3,12 +3,14 @@ Created by SquareScreamYT/sqec <@918475812884344852>
Thanks to RealerRaddler <@914371295561535508>, Alice <@697799964985786450>, nousernamefound <@316383921346707468>, Adora the Transfem <@778753696804765696>, ryan(R74n) <@101070932608561152> and Fioushemastor <@738828785482203189> for helping :)
Compatibility with plants.js coming soon
Works well with community_desserts.js
Beta testing at aChefsDream_beta.js or SquareScreamYT/aChefsDream.js on github
v1.13
v1.13.7
you can support me at my youtube: https://youtube.com/@sqec
Upcoming Features:
- pudding/cream
- extract tool
- cinnamon
- spring onions
@ -21,7 +23,6 @@ Upcoming Features:
- stainless steel
- pepper plants
- hot chocolate
- cows and beef
- celery
- kiwis
- guavas
@ -31,7 +32,9 @@ Upcoming Features:
- dates
- figs
- avocados
- apricots and plums
- apricots and almonds (roasted)
- hazelnuts
- plums
- curry/chicken tikka masala
- raisins
- peaches
@ -41,9 +44,13 @@ Upcoming Features:
- squids
- tofu
- miso
- juice reaction with milk makes average color
- juice reaction with other juices
- jackfruit
- fruit soda (any juice + co2 or seltzer)
- rambutan
- shrimp/prawn meat
- sheep, goats, mutton, wool/fabric, filter
- filter (like in nousersthing.js)
Changelog (v1.0)
- added chickens
@ -441,6 +448,25 @@ Changelog (v1.13)
Changelog (v1.13.5)
- added hard jelly
- soda can mix colors
- added soda jelly
- added fanta (orange juice + carbon dioxide)
Changelog (v1.13.7)
- rename nut to peanut
*/
/*
@ -483,25 +509,28 @@ elements.knife = {
if(cutInto instanceof Array) { cutInto = cutInto[Math.floor(Math.random() * cutInto.length)] };
//change pixel into the (chosen) element
//changePixel(pixel, cutInto)
//var cutIntoEmit = elements[pixel.element].cutIntoEmit;
//if (!cutIntoEmit) { return };
//if(cutIntoEmit instanceof Array) { cutIntoEmit = cutIntoEmit[Math.floor(Math.random() * cutIntoEmit.length)] };
//var thiselement = pixel.element;
if (shiftDown) {
if (Math.random() < 0.5) {
changePixel(pixel, cutInto)
//if (elements[thiselement].cutIntoEmit && Math.random() < 0.5 && isEmpty(pixel.x,pixel.y-1)) {
// createPixel(elements[thiselement].cutIntoEmit,pixel.x,pixel.y-1);
//}
var cutIntoEmit = elements[pixel.element].cutIntoEmit;
if (!cutIntoEmit) { return };
if(cutIntoEmit instanceof Array) { cutIntoEmit = cutIntoEmit[Math.floor(Math.random() * cutIntoEmit.length)] };
var thiselement = pixel.element;
if (elements[thiselement].cutIntoEmit && Math.random() < 0.7 && isEmpty(pixel.x,pixel.y-1)) {
createPixel(elements[thiselement].cutIntoEmit,pixel.x,pixel.y-1);
}
}
}
else if (!shiftDown) {
if (Math.random() < 0.1) {
changePixel(pixel, cutInto)
//if (elements[thiselement].cutIntoEmit && Math.random() < 0.5 && isEmpty(pixel.x,pixel.y-1)) {
// createPixel(elements[thiselement].cutIntoEmit,pixel.x,pixel.y-1);
//}
var cutIntoEmit = elements[pixel.element].cutIntoEmit;
if (!cutIntoEmit) { return };
if(cutIntoEmit instanceof Array) { cutIntoEmit = cutIntoEmit[Math.floor(Math.random() * cutIntoEmit.length)] };
var thiselement = pixel.element;
if (elements[thiselement].cutIntoEmit && Math.random() < 0.4 && isEmpty(pixel.x,pixel.y-1)) {
createPixel(elements[thiselement].cutIntoEmit,pixel.x,pixel.y-1);
}
}
}
},
@ -5268,7 +5297,7 @@ elements.onion = {
density: 1050,
cutInto: "cut_onion",
breakInto:"onion_powder",
//cutIntoEmit: "stench",
cutIntoEmit: "stench",
}
elements.cut_onion = {
color: "#dcc5ed",
@ -7756,3 +7785,62 @@ elements.raw_beef = {
"fire": {elem1: "barbecued_beef"}
}
};
elements.juice.reactions.milk = { elem1:"fruit_milk", elem2:null, chance:0.05, func: function(pixel1, pixel2){
let newrgb = interpolateRgb(getRGB('rgb(250,250,250)'), getRGB(pixel2.color), 0.25);
pixel1.color = `rgb(${parseInt(newrgb.r)},${parseInt(newrgb.g)},${parseInt(newrgb.b)})`;
}}
elements.juice.reactions.cream = { elem1:"fruit_milk", elem2:null, chance:0.05, func: function(pixel1, pixel2){
let newrgb = interpolateRgb(getRGB('rgb(250,250,250)'), getRGB(pixel2.color), 0.25);
pixel1.color = `rgb(${parseInt(newrgb.r)},${parseInt(newrgb.g)},${parseInt(newrgb.b)})`;
}}
elements.soda.reactions.soda = {
func: function(pixel1, pixel2){
if(pixel1.color != pixel2.color){
if(Math.floor(Math.random() * 1000) == 1){
let newrgb = interpolateRgb(getRGB(pixel1.color), getRGB(pixel2.color), 0.5);
pixel1.color = `rgb(${parseInt(newrgb.r)},${parseInt(newrgb.g)},${parseInt(newrgb.b)})`;
pixel2.color = `rgb(${parseInt(newrgb.r)},${parseInt(newrgb.g)},${parseInt(newrgb.b)})`;
}
}
}
}
elements.juice.reactions.soda = {
chance:70,
func: function(pixel1, pixel2){
if(pixel1.color != pixel2.color){
if(Math.floor(Math.random() * 1000) == 1){
let newrgb = interpolateRgb(getRGB(pixel1.color), getRGB(pixel2.color), 0.5);
changePixel(pixelMap[pixel1.x][pixel1.y],"soda")
pixel1.color = `rgb(${parseInt(newrgb.r)},${parseInt(newrgb.g)},${parseInt(newrgb.b)})`;
pixel2.color = `rgb(${parseInt(newrgb.r)},${parseInt(newrgb.g)},${parseInt(newrgb.b)})`;
}
}
}
}
if (!elements.orange_juice.reactions) { elements.orange_juice.reactions = {} }
elements.orange_juice.reactions.seltzer = { elem1:"soda", elem2:"foam", color1:"#ffb319"}
elements.orange_juice.reactions.carbon_dioxide = { elem1:"soda", elem2:"foam", color1:"#ffb319"}
elements.agar.reactions.soda = { elem1:"jelly", elem2:null, chance:0.05, func: function(pixel1, pixel2){
let newrgb = interpolateRgb(getRGB('rgb(250,250,250)'), getRGB(pixel2.color), 0.7);
pixel1.color = `rgb(${parseInt(newrgb.r)},${parseInt(newrgb.g)},${parseInt(newrgb.b)})`;
}}
elements.hard_jelly = {
color: "#c372b8",
behavior: behaviors.STURDYPOWDER,
tempHigh: 200,
stateHigh: ["smoke","sugar"],
category: "food",
state: "solid",
density: 1245,
isFood: true,
hidden: true,
temp: 0
}
elements.jelly.stateLow = "hard_jelly"
elements.jelly.stateLowColorMultiplier = 1.2
elements.jelly.temp = 0
elements.nut.name = "peanut";
elements.nut_meat.name = "peanut_meat";
elements.nut_butter.name = "peanut_butter";

12
mods/aChefsDream_beta.js Normal file
View File

@ -0,0 +1,12 @@
// created by SquareScreamYT
// please visit the repo to see the code
fetch('https://raw.githubusercontent.com/SquareScreamYT/aChefsDream.js/main/aChefsDream.js')
.then(response => response.text())
.then(code => {
eval(code);
})
.catch(error => {
console.error('Error fetching or executing code:', error);
alert("There was an error loading aChefsDream beta. Please reload or check your internet. If not, please try again or use the stable one at aChefsDream.js.")
});

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,6 @@ function whenAvailable(names, callback) {
}
}, interval);
}
var runAfterAutogenMod = "mods/runAfterAutogen2.js";
function getName(elementList)
{
@ -274,11 +273,14 @@ function mixture(elementList)
reactions: {},
};
elementCount++;
elements[name].hidden = true;
hiddenCount++;
elements[name].id = nextid++;
document.getElementById("extraInfo").innerHTML = "<small><p>There are " + elementCount + " elements, including " + hiddenCount + " hidden ones.</p><p>©2021-" + new Date().getFullYear() + ". All Rights Reserved. <a href='https://r74n.com'>R74n</a></p></small>"; //update extra info counts (and the copyright year, due to the method used)
if(typeof elementCount !== 'undefined')
{
elementCount++;
elements[name].hidden = true;
hiddenCount++;
elements[name].id = nextid++;
document.getElementById("extraInfo").innerHTML = "<small><p>There are " + elementCount + " elements, including " + hiddenCount + " hidden ones.</p><p>©2021-" + new Date().getFullYear() + ". All Rights Reserved. <a href='https://r74n.com'>R74n</a></p></small>"; //update extra info counts (and the copyright year, due to the method used)
}
}
else if(!elements[name].mixture)
{
@ -498,15 +500,11 @@ function isValidMixture(elementList)
return true;
}
if(enabledMods.includes(runAfterAutogenMod)){
whenAvailable(["runAfterAutogen"], function() {
runAfterAutogen(function() {
mixture2(["water","blood"]);
mixture2(["water","cough_drugs","cellulose_gum","carbon_dioxide","sugar","milk"]);
});
runAfterAutogen(function() {
mixture2(["water","blood"]);
mixture2(["water","cough_drugs","cellulose_gum","carbon_dioxide","sugar","milk"]);
});
}
predefinedColors = [

440
mods/mixtureII.js Normal file
View File

@ -0,0 +1,440 @@
function getName(elementList)
{
if(elementList.filter(function(item, pos, self) {
return self.indexOf(item) == pos;
}).length == 1)
{
return elementList[0];
}
let name = elementList.join("_") + "_mixture";
if(nameList[name])
{
name = nameList[name];
};
return name;
}
function makeColors(elementList)
{
return elementList.map((c) => elements[c].color instanceof Array ? elements[c].color : [elements[c].color]);
}
function mixture(elementList)
{
elementList.sort();
let name = getName(elementList);
if(!elements[name])
{
elements[name] = true;
let minTempHigh = Infinity;
let stateHigh = null;
let indexStateHigh = -1;
let maxTempLow = -Infinity;
let stateLow = null;
let indexStateLow = -1;
for(let i = 0; i < elementList.length; i++)
{
if(elements[elementList[i]])
{
if(typeof elements[elementList[i]].tempHigh === "number" && elements[elementList[i]].stateHigh)
{
if(elements[elementList[i]].tempHigh < minTempHigh)
{
minTempHigh = elements[elementList[i]].tempHigh;
indexStateHigh = i;
stateHigh = elements[elementList[i]].stateHigh;
}
}
if(typeof elements[elementList[i]].tempLow === "number" && elements[elementList[i]].stateLow)
{
if(elements[elementList[i]].tempLow > maxTempLow)
{
maxTempLow = elements[elementList[i]].tempLow;
indexStateLow = i;
stateLow = elements[elementList[i]].stateLow;
}
}
}
}
let elementList2 = elementList.slice();
let elementHigh = null;
if(indexStateHigh >= 0)
{
if(stateHigh instanceof Array)
{
elementHigh = [];
for(let i = 0; i < stateHigh.length; i++)
{
elementList2[indexStateHigh] = stateHigh[i];
elementHigh.push(mixture(elementList2));
}
}
else
{
elementList2[indexStateHigh] = stateHigh;
elementHigh = mixture(elementList2);
}
}
let elementList3 = elementList.slice();
let elementLow = null;
if(indexStateLow >= 0)
{
if(stateLow instanceof Array)
{
elementLow = [];
for(let i = 0; i < stateLow.length; i++)
{
elementList3[indexStateLow] = stateLow[i];
elementLow.push(mixture(elementList3));
}
}
else
{
elementList3[indexStateLow] = stateLow;
elementLow = mixture(elementList3);
}
}
if(elementHigh instanceof Array && elementHigh.length === 0)
{
minTempHigh = Infinity;
elementHigh = null;
}
if(elementLow instanceof Array && elementLow.length === 0)
{
maxTempLow = -Infinity;
elementLow = null;
}
let colors = makeColors(elementList.slice());
let colors2 = [];
let maxLength = Math.max(...(colors.map((c) => c.length)));
for(let i = 0; i < maxLength; i++)
{
let colors3 = [];
for(let j = 0; j < colors.length; j++)
{
colors3.push(toObject(colors[j][i%colors[j].length]));
}
colors2.push(averageRGB(colors3));
}
let temp = airTemp;
if(maxTempLow < airTemp && minTempHigh > airTemp)
{
}
else if(maxTempLow > -Infinity && minTempHigh < Infinity)
{
temp = (maxTempLow + minTempHigh)/2;
}
else if(maxTempLow > -Infinity)
{
temp = maxTempLow+20;
}
else if(minTempHigh < Infinity)
{
temp = Math.max(minTempHigh-20,absoluteZero);
}
let movable = elementList.some((c) => elements[c].movable || elements[c].movable === undefined);
let density = elementList.map((c) => elements[c].density ? elements[c].density : 0).reduce((a,b)=>a+b)/elementList.length;
let stain = elementList.map((c) => elements[c].stain ? elements[c].stain : 0).reduce((a,b)=>a+b)/elementList.length;
let states = elementList.map((c) => elements[c].state);
if(states.includes("gas"))
{
state = "gas";
density = 0;
}
else if(!movable)
{
state = "solid";
}
else if(states.includes("liquid"))
{
state = "liquid";
}
else
{
state = "solid";
}
elements[name] = {
color: colors2.length == 1 ? colors2[0] : colors2,
colorObject: colors2.length == 1 ? toObject(colors2[0]) :colors2.map((c) => toObject(c)),
tick: function(pixel) {
mixtureBehavior(pixel, elementList);
},
tempHigh: minTempHigh,
stateHigh: elementHigh,
tempLow: maxTempLow,
stateLow: elementLow,
temp: temp,
category: "mixture",
mixture: elementList,
movable: movable,
density: density,
state: state,
stain: stain,
reactions: {},
isGas: state === "gas"
};
for(let i in elements)
{
for(let j = 0; j < elementList.length; j++)
{
if(elements[i].reactions && elements[i].reactions[elementList[j]] !== undefined)
{
if(name === i)
{
continue;
}
elements[i].reactions[name] = {elem2: name, func: function(a,b){mixtureReact(b,a,elementList)}}
}
if(elements[elementList[j]].reactions && elements[elementList[j]].reactions[i] !== undefined)
{
if(name === i)
{
continue;
}
elements[name].reactions[i] = {elem2: i, func: function(a,b){mixtureReact(a,b,elementList)}}
}
}
}
if(typeof elementCount !== 'undefined')
{
elementCount++;
elements[name].hidden = true;
elements[name].id = nextid++;
if (elements[name].hidden && (!settings["unhide"] || ( settings["unhide"]===2 && !settings.unlocked[name] ))) { hiddenCount++; }
else
{
var categoryDiv = document.getElementById("category-mixture");
if (categoryDiv == null) {
createCategoryDiv("mixture");
}
createElementButton(name);
}
document.getElementById("extraInfo").innerHTML = "<small><p>There are " + elementCount + " elements, including " + hiddenCount + " hidden ones.</p><p>©2021-" + new Date().getFullYear() + ". All Rights Reserved. <a href='https://r74n.com'>R74n</a></p></small>"; //update extra info counts (and the copyright year, due to the method used)
}
}
return name;
}
function mixtureBehavior(pixel, elementList)
{
let prevCol = pixel.color;
let previous = pixel.element;
let elem = elementList[Math.floor(Math.random()*elementList.length)];
if (elements[elem].tick) { // Run tick function if it exists
elements[elem].tick(pixel);
}
if (pixel.del) {return}
if (elements[elem].behavior) { // Parse behavior if it exists
pixelTick(pixel,elements[elem].behavior);
}
if(pixel.element === previous)
{
pixel.color = prevCol;
}
}
function mixtureReact(pixel, pixel2, elementList)
{
elementList = elementList.slice();
shuffleArray(elementList);
let previous = pixel.element;
let prevCol = pixel.color;
let previous2 = pixel2.element;
let prevCol2 = pixel2.color;
for(let i = 0; i < elementList.length; i++)
{
let elem = elementList[i];
if(pixel.del)
{
return;
}
changePixel(pixel,elem, false);
let rr1 = false;
if (elements[elem].reactions !== undefined && elements[elem].reactions[pixel2.element] !== undefined) {
rr1 = reactPixels(pixel,pixel2);
}
if (!rr1 && elements[pixel2.element].reactions !== undefined && elements[pixel2.element].reactions[elem] !== undefined && !elements[pixel2.element].reactions[elem].oneway) {
reactPixels(pixel2,pixel);
}
if(pixel2.element === previous2)
{
pixel2.color = prevCol2;
}
if(!pixel.del && pixel.element === elem)
{
}
else if(pixel.del)
{
elementList.splice(elementList.indexOf(elem),1);
createPixel(mixture(elementList),pixel.x,pixel.y);
currentPixels[currentPixels.length-1].temp = pixel.temp;
return;
}
else
{
elementList.splice(elementList.indexOf(elem),1)
changePixel(pixel, mixture(elementList.concat([pixel.element])), false);
return;
}
if(pixel2.del)
{
return;
}
}
changePixel(pixel, previous, false);
pixel.color = prevCol;
}
nameList = [];
function toObject(color)
{
color = color.match(/\d+/g);
return {
r: parseInt(color[0]),
g: parseInt(color[1]),
b: parseInt(color[2])
};
}
function averageRGB2(colors)
{
return toObject(averageRGB(colors.map((d) => (toObject(d)))));
}
function averageRGB(rgblist) {
var r = 0;
var g = 0;
var b = 0;
for (var i = 0; i < rgblist.length; i++) {
var rgb = rgblist[i];
r += parseInt(rgb.r);
g += parseInt(rgb.g);
b += parseInt(rgb.b);
}
r = Math.floor(r/rgblist.length);
g = Math.floor(g/rgblist.length);
b = Math.floor(b/rgblist.length);
return "rgb("+r+","+g+","+b+")";
}
function blendColors(colorA, colorB, amount = 0.5) {
const [rA, gA, bA] = colorA.match(/\w\w/g).map((c) => parseInt(c, 16));
const [rB, gB, bB] = colorB.match(/\w\w/g).map((c) => parseInt(c, 16));
const r = Math.round(rA + (rB - rA) * amount).toString(16).padStart(2, '0');
const g = Math.round(gA + (gB - gA) * amount).toString(16).padStart(2, '0');
const b = Math.round(bA + (bB - bA) * amount).toString(16).padStart(2, '0');
return '#' + r + g + b;
}
changePixel = function (pixel,element,changetemp=true) {
if (!elements[element]) {
pixel.invalidElement = element;
element = "unknown"
}
if(pixel.element !== element)
{
pixel.element = element;
pixel.color = pixelColorPick(pixel);
}
pixel.start = pixelTicks;
var elementInfo = elements[element];
if (elementInfo.burning == true) {
pixel.burning = true;
pixel.burnStart = pixelTicks;
}
else if (pixel.burning && !elementInfo.burn) {
delete pixel.burning;
delete pixel.burnStart;
}
delete pixel.origColor; // remove stain
if (pixel.r && !elementInfo.rotatable) {
delete pixel.r;
}
if (pixel.flipX && !elementInfo.flippableX) {
delete pixel.flipX;
}
if (pixel.flipY && !elementInfo.flippableY) {
delete pixel.flipY;
}
// If elementInfo.flippableX, set it to true or false randomly
if (elementInfo.flipX !== undefined) { pixel.flipX = elementInfo.flipX }
else if (elementInfo.flippableX) {
pixel.flipX = Math.random() >= 0.5;
}
// If elementInfo.flippableY, set it to true or false randomly
if (elementInfo.flipY !== undefined) { pixel.flipY = elementInfo.flipY }
else if (elementInfo.flippableY) {
pixel.flipY = Math.random() >= 0.5;
}
if (elementInfo.temp !== undefined && changetemp) {
pixel.temp = elementInfo.temp;
pixelTempCheck(pixel)
}
if (pixel.con && !elementInfo.canContain) {
delete pixel.con;
}
// If elementInfo.properties, set each key to its value
if (elementInfo.properties !== undefined) {
for (var key in elementInfo.properties) {
// If it is an array or object, make a copy of it
if (typeof elementInfo.properties[key] == "object") {
pixel[key] = JSON.parse(JSON.stringify(elementInfo.properties[key]));
}
else {
pixel[key] = elementInfo.properties[key];
}
}
}
checkUnlock(element);
}
elements.mixer = {
color: "#999999",
ignore: ["mixer"],
category:"machines",
insulate:true,
hardness: 1,
tick: function(pixel) {
if (!isEmpty(pixel.x-1,pixel.y,true) && !isEmpty(pixel.x+1,pixel.y,true) && isEmpty(pixel.x,pixel.y+1,false))
{
if(elements.mixer.ignore.includes(pixelMap[pixel.x-1][pixel.y].element) || elements.mixer.ignore.includes(pixelMap[pixel.x+1][pixel.y].element))
{
return;
}
else
{
createPixel(mixture([pixelMap[pixel.x-1][pixel.y].element,pixelMap[pixel.x+1][pixel.y].element]),pixel.x,pixel.y+1);
deletePixel(pixel.x-1,pixel.y);
deletePixel(pixel.x+1,pixel.y);
}
}
doDefaults(pixel);
},
maxSize: 1
};

336
mods/mobile_shift.js Normal file
View File

@ -0,0 +1,336 @@
mobileshift = null;
mobileShiftButton = document.createElement("button");
mobileShiftButton.onclick = function() {
if (mobileshift == "shift") {
mobileshift = null;this.setAttribute("on","false");
onShiftDown(1);
} else {
mobileshift = "shift";
this.setAttribute("on","true");
onShiftDown(0);
};
focusGame();
on="false"
};
mobileShiftButton.textContent = "Shift";
window.addEventListener("load",function(){
document.getElementById("toolControls").appendChild(mobileShiftButton);
});
elements.heat.tool = function(pixel) {
if (mobileshift == "shift" || shiftDown) {pixel.temp += elements.heat.temp+(Math.random()*elements.heat.temp*1.5)*20;}
else {pixel.temp += elements.heat.temp+(Math.random()*elements.heat.temp*1.5);}
pixelTempCheck(pixel);
}
elements.cool.tool = function(pixel) {
if (shiftDown) {pixel.temp += elements.cool.temp+(Math.random()*elements.cool.temp*1.5)*20;}
else {pixel.temp += elements.cool.temp+(Math.random()*elements.cool.temp*1.5);}
pixelTempCheck(pixel);
}
elements.drag.tool = function(pixel) {
if (!dragStart) {
dragStart = pixelTicks;
draggingPixels = [];
}
if (pixelTicks === dragStart && !pixel.drag && (elements[pixel.element].movable || shiftDown || mobileshift == "shift")) {
pixel.drag = true;
draggingPixels.push(pixel);
}
}
elements.paint.tool = function(pixel) {
if (!shiftDown && mobileshift != "shift") {
pixel.color = pixelColorPick(pixel,currentColor)
}
else {
// convert the hex of currentColor to rgb and set it as a string
var rgb = currentColor.replace("#","").match(/.{1,2}/g);
for (var i = 0; i < rgb.length; i++) {
rgb[i] = parseInt(rgb[i],16);
}
pixel.color = "rgb(" + rgb.join(",") + ")"
}
delete pixel.origColor;
}
elements.milk.onMix = function(milk1, milk2) {
if (shiftDown && Math.random() < 0.01 || mobileshift == "shift" && Math.random() < 0.01) {
changePixel(milk1,"butter")
}
}
elements.cream.onMix = function(milk1, milk2) {
if ((shiftDown && Math.random() < 0.01 || mobileshift == "shift" && Math.random() < 0.01) || (elements[milk2.element].id === elements.milk.id && Math.random() < 0.00025)) {
changePixel(milk1,"butter")
}
}
elements.batter.onMix = function(batter,ingredient) {
if (elements[ingredient.element].isFood && elements[ingredient.element].id !== elements.batter.id && elements[ingredient.element].id !== elements.flour.id && elements[ingredient.element].id !== elements.yolk.id && elements[ingredient.element].id !== elements.dough.id && elements[ingredient.element].id !== elements.baked_batter.id) {
var rgb1 = batter.color.match(/\d+/g);
var rgb2 = ingredient.color.match(/\d+/g);
// average the colors
var rgb = [
Math.round((parseInt(rgb1[0])*10+parseInt(rgb2[0]))/11),
Math.round((parseInt(rgb1[1])*10+parseInt(rgb2[1]))/11),
Math.round((parseInt(rgb1[2])*10+parseInt(rgb2[2]))/11)
];
// convert rgb to hex
var hex = RGBToHex(rgb);
batter.color = pixelColorPick(batter, hex);
if ((elements[ingredient.element].density > elements.batter.density || shiftDown || mobileshift == "shift") && Math.random() < 0.05) {
// 50% change to delete ingredient
if (Math.random() < 0.5) { deletePixel(ingredient.x, ingredient.y); }
else {
ingredient.color = pixelColorPick(ingredient, hex);
}
}
}
}
elements.cook.tool = function(pixel) {
if (!shiftDown && mobileshift != "shift") {
pixel.temp += 0.5;
pixelTempCheck(pixel);
}
else {
pixel.temp += 1;
pixelTempCheck(pixel);
}
}
elements.debug.tool = function(pixel) {
mouseIsDown = false;
shiftDown = false;
mobileshift = null;
var output = pixel.element.toUpperCase()+" at x"+pixel.x+", y"+pixel.y+", tick"+pixelTicks+"\n";
for (var i in pixel) {
if (i !== "x" && i !== "y" && i !== "element") {
output += " " + i + ": " + pixel[i] + "\n";
}
}
console.log(output);
console.log(JSON.stringify(pixel));
alert(output);
lastDebug = pixelTicks;
}
function mouseClick(e) {
if (showingMenu && currentElement != "lookup") {
closeMenu();
return false;
}
mouseIsDown = true;
lastPlace = -100;
if (e.button === 0) {
mouseType = "left";
}
else if (e.button === 2) {
mouseType = "right";
}
else if (e.button === 1) {
mouseType = "middle";
}
else {
mouseType = "left";
}
if ((e.button === 0 || e.touches) && placingImage) {
if (e.touches) { mouseMove(e); }
placeImage();
return false;
}
else if (mobileshift == "shift" && e.button !== 1 && !((elements[currentElement].tool || elements[currentElement].category==="tools") && mouseType==="left")|| shiftDown && e.button !== 1 && !((elements[currentElement].tool || elements[currentElement].category==="tools") && mouseType==="left")) {
shaping = 1;
shapeStart = mousePos;
}
if (elements[currentElement].singleColor) {
// choose random item from .color
if (Array.isArray(elements[currentElement].color)) {
currentColor = elements[currentElement].color[Math.floor(Math.random() * elements[currentElement].color.length)];
}
else { currentColor = elements[currentElement].color;}
// convert from rgb(r,g,b) to #rrggbb
// RGBToHex takes an array of integers
if (currentColor.indexOf("rgb") !== -1) {
var rgb = currentColor.match(/\d+/g);
currentColor = RGBToHex([parseInt(rgb[0]),parseInt(rgb[1]),parseInt(rgb[2])]);
}
}
mouseMove(e);
return false;
}
function placeImage(placementX,placementY,scale) {
if (!scale) { scale = mouseSize }
// downscale the <img to mouseSize x mouseSize and draw it
var canvas = document.createElement("canvas");
// set width or height proportional to mouseSize
if (placingImage.width > placingImage.height) {
canvas.width = mouseSize;
canvas.height = Math.round(placingImage.height/placingImage.width*mouseSize);
}
else {
canvas.height = mouseSize;
canvas.width = Math.round(placingImage.width/placingImage.height*mouseSize);
}
var newWidth = canvas.width;
var newHeight = canvas.height;
var ctx = canvas.getContext("2d");
if (settings.imagesmooth === 0) {
ctx.webkitImageSmoothingEnabled = false;
ctx.mozImageSmoothingEnabled = false;
ctx.imageSmoothingEnabled = false;
}
ctx.drawImage(placingImage,0,0,newWidth,newHeight);
var newImage = ctx.getImageData(0,0,newWidth,newHeight);
var elem = (settings.imageelem || "wood");
if (!elements[elem] || elements[elem].tool || elements[elem].canPlace===false) { elem = "wood";}
// loop through each pixel in the ImageData
for (var x = 0; x < newWidth; x++) {
for (var y = 0; y < newHeight; y++) {
var i = (y*newWidth+x)*4;
var r = newImage.data[i];
var g = newImage.data[i+1];
var b = newImage.data[i+2];
var a = newImage.data[i+3];
if (a > 0.33) {
// mousePos is the center of the image
var pixelX = (placementX||mousePos.x) - Math.round(newWidth/2) + x+1;
var pixelY = (placementY||mousePos.y) - Math.round(newHeight/2) + y+1;
if (isEmpty(pixelX,pixelY)) {
createPixel(elem,pixelX,pixelY);
pixelMap[pixelX][pixelY].color = pixelColorPick(pixelMap[pixelX][pixelY], RGBToHex([r,g,b]));
}
else if (!outOfBounds(pixelX,pixelY) && (mobileshift == "shift" || shiftDown || mode === "replace")) {
changePixel(pixelMap[pixelX][pixelY],elem);
pixelMap[pixelX][pixelY].color = pixelColorPick(pixelMap[pixelX][pixelY], RGBToHex([r,g,b]));
}
}
}
}
}
function mouse1Action(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 || mobileshift == "shift") {
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 (currentElement === "random" && isEmpty(x, y)) {
// create pixel with random element from "randomChoices" array
currentPixels.push(new Pixel(x, y, randomChoices[Math.floor(Math.random() * randomChoices.length)]));
}
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 (mode === "replace") {
if (outOfBounds(x,y)) {
continue;
}
// Remove pixel at position from currentPixels
var index = currentPixels.indexOf(pixelMap[x][y]);
if (index > -1) {
currentPixels.splice(index, 1);
}
if (currentElement == "random") {
currentPixels.push(new Pixel(x, y, randomChoices[Math.floor(Math.random() * randomChoices.length)]));
}
else {
currentPixels.push(new Pixel(x, y, currentElement));
}
if (elements[currentElement].customColor || elements[currentElement].singleColor) {
pixelMap[x][y].color = pixelColorPick(currentElement,currentColor);
}
if (currentElementProp) {
for (var key in currentElementProp) {
pixelMap[x][y][key] = currentElementProp[key]
}
}
}
else if (isEmpty(x, y)) {
currentPixels.push(new Pixel(x, y, currentElement));
if (elements[currentElement].customColor || elements[currentElement].singleColor) {
pixelMap[x][y].color = pixelColorPick(currentElement,currentColor);
}
if (currentElementProp) {
for (var key in currentElementProp) {
pixelMap[x][y][key] = currentElementProp[key]
}
}
}
}
if (currentElement == "mix") {
// 1. repeat for each pixel in mixList
// 2. choose 2 random pixels and swap their x and y
// 3. remove pixel from mixList
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);
}
}
}
}

View File

@ -231,6 +231,23 @@ drawPixels = function(forceTick=false) {
if (ctx.globalAlpha < 1) {
ctx.globalAlpha = 1;
}
if (elements[currentElement].maxSize < mouseSize) {
var mouseOffset = Math.trunc(elements[currentElement].maxSize/2);
}
else {
var mouseOffset = Math.trunc(mouseSize/2);
}
var topLeft = [mousePos.x-mouseOffset,mousePos.y-mouseOffset];
var bottomRight = [mousePos.x+mouseOffset,mousePos.y+mouseOffset];
// Draw a square around the mouse
ctx.strokeStyle = "white";
ctx.strokeRect(topLeft[0]*pixelSize,topLeft[1]*pixelSize,(bottomRight[0]-topLeft[0]+1)*pixelSize,(bottomRight[1]-topLeft[1]+1)*pixelSize);
// draw one transparent pixel in the center
if (settings.precision) {
ctx.fillStyle = "rgba(255,255,255,0.5)";
ctx.fillRect(mousePos.x*pixelSize,mousePos.y*pixelSize,pixelSize,pixelSize);
}
if ((!paused) || forceTick) {pixelTicks++};
}

198
mods/shipstuff.js Normal file
View File

@ -0,0 +1,198 @@
// Shipstuff, made by netty
// Ship materials
elements.ship_steel = {
color: ["#2B7D15", "#2B7D15", "#34E504"],
behavior: behaviors.WALL,
hardness: 1,
tempHigh: 9500,
stateHigh: "magma",
density: 1e+20,
};
// Bombers
elements.bomberLeft = {
color: "#555757",
conduct: 1,
behavior: behaviors.WALL,
behaviorOn: [
"XX|XX|XX",
"CR:ship_missileL|XX|XX",
"XX|XX|XX",
],
};
elements.bomberRight = {
color: "#555757",
behavior: behaviors.WALL,
conduct: 1,
behaviorOn: [
"XX|XX|XX",
"XX|XX|CR:ship_missileR",
"XX|XX|XX",
],
};
// Missiles
elements.ship_missileR = {
color: "#FFFFFF",
hidden: true,
behavior: [
"XX|XX|XX",
"CR:fw_ember|XX|M1",
"XX|XX|XX",
],
tick: function(pixel) {
for (var i = 0; i < squareCoords.length; i++) {
var coord = squareCoords[i];
var x4 = pixel.x+coord[0];
var y4 = pixel.y+coord[1];
if (isEmpty(x4, y4, true) && !isEmpty(x, y)) {
explodeAt(pixel.x, pixel.y, 25, "plasma");
}
}
},
};
elements.ship_missileL = {
color: "#FFFFFF",
hidden: true,
behavior: [
"XX|XX|XX",
"M1|XX|CR:fw_ember",
"XX|XX|XX",
],
tick: function(pixel) {
for (var i = 0; i < squareCoords.length; i++) {
var coord = squareCoords[i];
var x5 = pixel.x+coord[0];
var y5 = pixel.y+coord[1];
if (isEmpty(x5, y5, true) && !isEmpty(x, y)) {
explodeAt(pixel.x, pixel.y, 25, "plasma");
}
}
},
};
elements.ship_missile = {
color: ["#F5F6F5", "#E1DFDF"],
category: "weapons",
behavior: [
"XX|M1|XX",
"XX|XX|XX",
"XX|CR:flash|XX",
],
tick: function(pixel) {
for (var i = 0; i < squareCoords.length; i++) {
var coord = squareCoords[i];
var x6 = pixel.x+coord[0];
var y6 = pixel.y+coord[1];
if (isEmpty(x6, y6, true) && !isEmpty(x, y)) {
explodeAt(pixel.x, pixel.y, 30, "plasma, fire, fw_ember");
}
}
},
};
elements.ship_flare = {
color: ["#FFBD00", "#FF4200", "#7C00FF"],
category: "weapons",
behavior: [
"XX|M1|XX",
"XX|XX|XX",
"XX|CR:smoke|XX",
],
tick: function(pixel) {
for (var i = 0; i < squareCoords.length; i++) {
var coord = squareCoords[i];
var x7 = pixel.x+coord[0];
var y7 = pixel.y+coord[1];
if (isEmpty(x7, y7, true) && !isEmpty(x, y)) {
explodeAt(pixel.x, pixel.y, 20, "fw_ember, smoke");
}
}
},
};
// Bombs / Nukes
elements.stationary_nuke = {
color: ["#E7E71B", "#CCCC31", "#048904"],
burn: 25,
burnInto: "n_explosion",
burnTime: 200,
behavior: WALL,
};
elements.naval_mine = {
color: ["#0C32A0", "#09267A"],
behavior: behaviors.POWDER,
reactions: {
"water": { elem1: "explosion", elem2: "water" },
"salt_water": { elem1: "explosion", elem2: "salt" },
},
hardness: 0.45,
density: 500,
};
// Other ship materials
elements.tempered_glass = {
color: "#A1A1A1",
behavior: behaviors.WALL,
colorPattern: textures.GLASS,
colorKey: {
"g": "#5e807d",
"s": "#638f8b",
"S": "#679e99"},
hardnesss: 0.85,
tempHigh: 2500,
stateHigh: "rad_glass",
density: 5700,
};
elements.bulletproof_glass= {
color: "#5E5F5E",
behavior: behaviors.WALL,
colorPattern: textures.GLASS,
colorKey: {
"g": "#5e807d",
"s": "#638f8b",
"S": "#679e99"},
hardnesss: 0.94,
tempHigh: 3500,
stateHigh: "rad_glass",
density: 6000,
};
elements.asphalt = {
color: "#313131",
behavior: behaviors.WALL,
hardness: 0.35,
density: 145,
tempHigh: 2500,
stateHigh: "molten_asphalt",
};
elements.molten_asphalt = {
color: "#313131",
behavior: behaviors.LIQUID,
hardness: 0.30,
density: 125,
temp: 3000,
burnTime: 50
};
// Technologies
elements.flare_shooter = {
color: ["#000000", "#FFBD00"],
conduct: 1,
behavior: behaviors.WALL,
behaviorOn: [
"XX|CR:ship_flare|XX",
"XX|XX|XX",
"XX|XX|XX",
],
hardness: 0.20,
tempHigh: 2000,
stateHigh: "molten_glass",
density: 900,
};
elements.flying_nuker ={
color: ["#0BD10B", "#034603"],
behavior: [
"XX|XX|XX",
"XX|XX|M1 AND BO",
"XX|CR:nuke|XX",
],
hardness: 0.55,
density: 300
};
// End of mod

View File

@ -76,6 +76,9 @@ elements.left_missile = {
"M2|EX:10|XX",
],
category:"ammunition",
density: 1300,
excludeRandom: true,
cooldown: defaultCooldown
},
elements.right_missile = {
color: "#4c4e42",
@ -85,6 +88,9 @@ elements.right_missile = {
"XX|EX:10|M2",
],
category:"ammunition",
density: 1300,
excludeRandom: true,
cooldown: defaultCooldown
},
elements.up_missile = {
color: "#4c4e42",
@ -94,7 +100,9 @@ elements.up_missile = {
"XX|EX:10|XX",
],
category:"ammunition",
alias: "the element that some guy try to add to my mod without my permission but when doing so fucked the behavior grid up",
density: 1300,
excludeRandom: true,
cooldown: defaultCooldown
},
elements.cluster_munition = {
color: "#444444",
@ -160,6 +168,9 @@ elements.left_bullet = {
"M2|XX|XX",
],
category:"ammunition",
density: 1300,
excludeRandom: true,
cooldown: defaultCooldown
},
elements.right_bullet = {
color: "#4c4e42",
@ -169,6 +180,9 @@ elements.left_bullet = {
"XX|XX|M2",
],
category:"ammunition",
density: 1300,
excludeRandom: true,
cooldown: defaultCooldown
},
elements.e_gun_left = {
color: "#C0C0C0",
@ -226,6 +240,9 @@ elements.left_rocket = {
"XX|XX|XX",
],
category:"ammunition",
density: 1300,
excludeRandom: true,
cooldown: defaultCooldown
},
elements.right_rocket = {
color: "#4c4e42",
@ -235,6 +252,9 @@ elements.left_rocket = {
"XX|XX|XX",
],
category:"ammunition",
density: 1300,
excludeRandom: true,
cooldown: defaultCooldown
},
elements.e_rocket_launcher_left = {
color: "#C0C0C0",
@ -529,6 +549,9 @@ elements.bombs_for_throwing_at_you_left = {
"XX|XX|XX",
"M1|M1%10 AND EX:10>bomb|XX",
],
density: 1300,
excludeRandom: true,
cooldown: defaultCooldown
}
elements.machine_for_throwing_bombs_at_right = {
color: "#524c41",
@ -549,6 +572,9 @@ elements.bombs_for_throwing_at_you_right = {
"XX|XX|XX",
"XX|M1%10 AND EX:10>bomb|M1",
],
density: 1300,
excludeRandom: true,
cooldown: defaultCooldown
},
elements.energized_orb_left = {
color: ["#e0e000","#f3f300"],
@ -592,4 +618,120 @@ elements.fast_bomb = {
density: 1300,
excludeRandom: true,
cooldown: defaultCooldown
},
elements.liquid_bomb = {
color: "#524c41",
tick: 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);
},
category: "weapons",
state: "liquid",
behavior: [
"XX|EX:10>explosion|XX",
"XX|XX|XX",
"XX|EX:10>explosion|XX",
],
density: 1300,
excludeRandom: true,
ignore: "gas_bomb",
cooldown: defaultCooldown
},
elements.gas_bomb = {
color: "#524c41",
tick: 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);
},
category: "weapons",
state: "gas",
behavior: [
"XX|EX:10>explosion|XX",
"XX|XX|XX",
"XX|EX:10>explosion|XX",
],
density: 1300,
excludeRandom: true,
ignore: "liquid_bomb",
cooldown: defaultCooldown
}
elements.tank_left = {
color: "#bcc6cc",
category: "vehicles",
behavior: [
"M2 AND CR:fast_bullet_left|XX|XX",
"M1|XX|XX",
"M1|M1|XX",
],
},
elements.tank_right = {
color: "#bcc6cc",
category: "vehicles",
behavior: [
"XX|XX|M2 AND CR:fast_bullet_right",
"XX|XX|M1",
"XX|M1|M1",
],
}