This commit is contained in:
slweeb 2025-03-05 22:46:48 -05:00
commit ca8c90fefe
8 changed files with 2170 additions and 2398 deletions

View File

@ -269,6 +269,7 @@
<!----><tr><td class="modCat" colspan="3">Food & Cooking</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>aChefsDream2.js</td><td>The sequel to aChefsDream.js, with brand new elements and tools</a></td><td>SquareScreamYT</td></tr>
<tr><td>aChefsDream.js</td><td>More foods, animals, tools, and other cooking items. See the <a href="https://www.youtube.com/watch?v=pQFTtlNPODQ&list=PLWHqGb75vC8o7CLv-pMoVb56JL9BY9F0t">YouTube Playlist</a> for updates</td><td>SquareScreamYT</td></tr>
<tr><td>bananas.js</td><td>Adds bananas and banana plants</td><td>Alice</td></tr>
<tr><td>CherrySoda.js</td><td>Adds materials to make Cherry soda. Benzaldehyde + seltzer = Cherrysoda.</td><td>guzzo86</td></tr>

View File

@ -3120,12 +3120,32 @@ elements.ginger = {
burnTime: 60,
burnInto: "dirt",
breakInto: "ginger_juice",
cutInto: "cut_ginger",
category: "food",
state: "solid",
density: 1250,
conduct: 0.1,
hidden: true
}
elements.cut_ginger = {
color: "#ffdd80",
behavior: [
"XX|XX|XX",
"XX|XX|XX",
"M2|M1|M2",
],
category:"food",
tempHigh: 100,
stateHigh: "steam",
burn:15,
burnTime:60,
burnInto: "steam",
breakInto: "juice",
breakIntoColor:"#ffe396",
state: "solid",
density: 1050,
hidden: true
}
elements.ginger_rhizome = {
color: "#c7ad58",
@ -7881,7 +7901,6 @@ elements.tempura = {
temp: 40,
tempHigh: 600,
stateHigh: ["ash", "smoke"],
tempLow: -20,
breakInto: "crumb",
isFood: true,
density: 100,

327
mods/aChefsDream2.js Normal file
View File

@ -0,0 +1,327 @@
// created by SquareScreamYT
// the sequel to aChefsDream!
runAfterLoad(function() {
console.log("Thanks for using aChefsDream2.js! -sqec")
console.log("You may find the prequel at aChefsDream.js")
})
var mods_to_include = ["mods/aChefsDream.js"]
var mods_included = mods_to_include.map(mod => enabledMods.includes(mod));
var all_mods_included = mods_included.reduce(function(a,b) { return a && b });
if(!all_mods_included) {
var mods_needed = mods_to_include.filter(function(modPath) { return !(enabledMods.includes(modPath)) });
mods_needed.forEach(function(modPath) {
enabledMods.splice(enabledMods.indexOf("mods/aChefsDream2"),0,modPath);
});
localStorage.setItem("enabledMods", JSON.stringify(enabledMods));
}
// Pork and Pigs
elements.pig = {
color: ["#9c6732", "#dbb997", "#fcaeae"],
behavior: [
"M2%1|XX|M2%1",
"M2%10|XX|M2%10",
"XX|M1|XX",
],
category:"life",
state: "solid",
reactions: {
"petal": { elem2:null, chance:0.2, func:behaviors.FEEDPIXEL },
"corn": { elem2:null, chance:0.3, func:behaviors.FEEDPIXEL },
"lettuce": { elem2:null, chance:0.3, func:behaviors.FEEDPIXEL },
"wheat": { elem2:null, chance:0.3, func:behaviors.FEEDPIXEL },
"grass": { elem2:null, chance:0.1, func:behaviors.FEEDPIXEL },
"grape": { elem2:null, chance:0.3, func:behaviors.FEEDPIXEL },
"pumpkin_seed": { elem2:null, chance:0.3, func:behaviors.FEEDPIXEL },
"pumpkin": { elem2:null, chance:0.1, func:behaviors.FEEDPIXEL },
"nut": { elem2:null, chance:0.2, func:behaviors.FEEDPIXEL },
"lichen": { elem2:null, chance:0.2, func:behaviors.FEEDPIXEL },
"oxygen": { elem2:"carbon_dioxide", chance:0.3 },
"mercury": { elem1:"rotten_meat", chance:0.1 },
"bleach": { elem1:"rotten_meat", chance:0.1 },
"infection": { elem1:"rotten_meat", chance:0.025 },
"uranium": { elem1:"rotten_meat", chance:0.1 },
"cyanide": { elem1:"rotten_meat", chance:0.1 },
"chlorine": { elem1:"meat", chance:0.1 },
"dirty_water": { elem1:"rotten_meat", chance:0.0001 },
},
egg: "piglet",
foodNeed: 10,
temp: 40,
tempHigh: 75,
stateHigh: "cooked_pork",
tempLow: -18,
stateLow: "frozen_meat",
breakInto: "raw_pork",
burn:85,
burnTime:450,
state: "solid",
density: 1117,
conduct: 0.3,
extractInto: "raw_pork",
};
elements.piglet = {
color: ["#f7bebe", "#d1a88e"],
behavior: [
"M2%1|XX|M2%1",
"M2%10|FX%5 AND CH:pig%0.1|M2%10",
"XX|M1|XX",
],
category: "life",
state: "solid",
foodNeed: 20,
temp: 40,
tempHigh: 75,
stateHigh: "cooked_pork",
tempLow: -18,
stateLow: "frozen_meat",
breakInto: "blood",
burn:85,
burnTime:450,
state: "solid",
density: 900,
conduct: 0.1,
reactions: {
"petal": { elem2:null, chance:0.2, func:behaviors.FEEDPIXEL },
"corn": { elem2:null, chance:0.3, func:behaviors.FEEDPIXEL },
"lettuce": { elem2:null, chance:0.3, func:behaviors.FEEDPIXEL },
"wheat": { elem2:null, chance:0.3, func:behaviors.FEEDPIXEL },
"grass": { elem2:null, chance:0.1, func:behaviors.FEEDPIXEL },
"grape": { elem2:null, chance:0.3, func:behaviors.FEEDPIXEL },
"pumpkin_seed": { elem2:null, chance:0.3, func:behaviors.FEEDPIXEL },
"pumpkin": { elem2:null, chance:0.1, func:behaviors.FEEDPIXEL },
"nut": { elem2:null, chance:0.2, func:behaviors.FEEDPIXEL },
"lichen": { elem2:null, chance:0.2, func:behaviors.FEEDPIXEL },
"oxygen": { elem2:"carbon_dioxide", chance:0.3 },
"mercury": { elem1:"rotten_meat", chance:0.1 },
"bleach": { elem1:"rotten_meat", chance:0.1 },
"infection": { elem1:"rotten_meat", chance:0.025 },
"uranium": { elem1:"rotten_meat", chance:0.1 },
"cyanide": { elem1:"rotten_meat", chance:0.1 },
"chlorine": { elem1:"meat", chance:0.1 },
"dirty_water": { elem1:"rotten_meat", chance:0.0001 },
},
};
elements.barbecued_pork = {
color:["#a1391f","#ab5e32"],
behavior: behaviors.STURDYPOWDER,
category: "food",
state: "solid",
temp:55,
tempHigh: 600,
stateHigh: ["ash","smoke"],
isFood: true,
hidden: true,
}
elements.cooked_pork = {
color: ["#e6bf8a", "#e3be96"],
behavior: behaviors.STURDYPOWDER,
category: "food",
state: "solid",
temp: 40,
tempHigh: 600,
stateHigh: ["ash", "smoke"],
hidden: true,
alias: "cooked_pork"
};
elements.raw_pork = {
color: ["#ed5d47", "#e0423d"],
behavior: behaviors.STURDYPOWDER,
category: "food",
state: "solid",
burnInto: "cooked_pork",
temp:25,
tempHigh: 200,
stateHigh: "cooked_pork",
reactions: {
"charcoal": {elem1: "barbecued_pork", tempMin: 70},
"fire": {elem1: "barbecued_pork"}
}
};
// Extraction tool
elements.extract = {
color: "#82452c",
// other needed properties
tool: (pixel) => {
//store extractInto as a variable for legibility
var extractInto = elements[pixel.element].extractInto;
//if theres no extractInto, it should equal undefined, which is falsey and !undefined = true
if (!extractInto) { return };
//if extractInto is an array, randomly pick one of its elements
if(extractInto instanceof Array) { extractInto = extractInto[Math.floor(Math.random() * extractInto.length)] };
//change pixel into the (chosen) element
if (shiftDown) {
if (Math.random() < 0.5) {
var thiselement = pixel.element;
changePixel(pixel, extractInto)
pixelTempCheck(pixel);
if (elements[thiselement].extractIntoColor) {
pixel.color = pixelColorPick(pixel, elements[thiselement].extractIntoColor);
}
}
}
else if (!shiftDown) {
if (Math.random() < 0.1) {
var thiselement = pixel.element;
changePixel(pixel, extractInto)
pixelTempCheck(pixel);
if (elements[thiselement].extractIntoColor) {
pixel.color = pixelColorPick(pixel, elements[thiselement].extractIntoColor);
}
}
}
},
category: "tools",
canPlace: false,
desc: "Use on pixels to extract the essence from them, if possible. [BETA]"
}
// spices
elements.allspice = {
color: ["#7B5B3A", "#A75B3D", "#B67B57", "#C19A6B"],
behavior: behaviors.POWDER,
category: "food",
state: "solid",
isFood: true,
temp: 20,
hidden: true,
tempHigh: 250,
stateHigh: ["ash", "smoke"],
}
elements.cumin = {
color: "#A58459",
behavior: behaviors.POWDER,
category: "food",
state: "solid",
isFood: true,
temp: 20,
hidden: true,
tempHigh: 250,
stateHigh: ["ash", "smoke"],
}
elements.paprika = {
color: ["#C72C29","#b22b02"],
behavior: behaviors.POWDER,
category: "food",
state: "solid",
isFood: true,
temp: 20,
hidden: true,
tempHigh: 250,
stateHigh: ["ash", "smoke"],
}
elements.turmeric = {
color: ["#E5B635","#D9A322"],
behavior: behaviors.POWDER,
category: "food",
state: "solid",
isFood: true,
temp: 20,
hidden: true,
tempHigh: 250,
stateHigh: ["ash", "smoke"],
}
elements.saffron = {
color: ["#b83b3b","#a82525"],
behavior: behaviors.POWDER,
category: "food",
state: "solid",
isFood: true,
temp: 20,
hidden: true,
tempHigh: 250,
stateHigh: ["ash", "smoke"],
}
elements.sugarcane_plant = {
color: ["#fbc852","#dfad54"],
behavior: [
"XX|M2%2|XX",
"XX|L2:sugarcane AND C2:sugarcane%10|XX",
"XX|M1|XX",
],
tick: behaviors.SEEDRISE,
tempHigh: 100,
stateHigh: "dead_plant",
tempLow: -2,
stateLow: "sugarcane",
burn: 30,
burnTime: 100,
category: "life",
state: "solid",
density: 686,
breakInto: "cane_sugar",
cooldown: defaultCooldown,
seed: true
}
elements.sugarcane = {
color: ["#7cc05c","#77a052"],
behavior: behaviors.STURDYPOWDER,
tempHigh: 380,
stateHigh: ["ember","fire","fire","fire"],
burn: 10,
burnTime: 200,
burnInto: ["ember","fire","fire","fire"],
category: "food",
state: "solid",
density: 686,
breakInto: "cane_sugar",
seed: "sugarcane_plant"
}
elements.cane_sugar = {
color: "#ffeedb",
behavior: behaviors.POWDER,
reactions: {
"grape": { elem1:null, elem2:"jelly", chance:0.005, tempMin:100 },
"water": { elem1:null, elem2:"sugar_water"},
},
category: "food",
tempHigh: 186,
stateHigh: "caramel",
state: "solid",
density: 1590,
isFood: true
}
elements.tea_leaves = {
color: ["#3e6e26","#507e28","#759e2e"],
reactions: {
"water": { elem2:"tea", tempMin:80 },
"salt_water": { elem2:"tea", tempMin:80 },
"sugar_water": { elem2:"tea", tempMin:80 },
"seltzer": { elem2:"tea", tempMin:80 },
"stench": { elem2:null, chance:0.25 },
"steam": { elem2:"fragrance", chance:0.1 },
"flea": { elem2:null, chance:0.01 },
"termite": { elem2:null, chance:0.01 },
"fly": { elem2:null, chance:0.01 },
"ant": { elem2:null, chance:0.01 },
"stink_bug": { elem2:null, chance:0.01 },
},
behavior: behaviors.POWDER,
tempHigh: 300,
stateHigh: ["fire","smoke","smoke","smoke","ash"],
tempLow: -2,
stateLow: "frozen_plant",
burn:10,
burnTime:300,
burnInto: ["fire","smoke","smoke","smoke","smoke","smoke","smoke","fragrance"],
category:"food",
state: "solid",
density: 1400,
isFood: true,
}

View File

@ -1,4 +1,4 @@
var mods_to_include = ["mods/sbstuff.js","mods/ketchup_mod.js","mods/morefoodsmod.js","mods/weAllScreamFor.js","mods/soups.js","mods/pizzasstuff.js","mods/community_desserts.js","mods/plants.js","mods/aChefsDream.js"]
var mods_to_include = ["mods/sbstuff.js","mods/ketchup_mod.js","mods/morefoodsmod.js","mods/weAllScreamFor.js","mods/soups.js","mods/pizzasstuff.js","mods/community_desserts.js","mods/plants.js","mods/aChefsDream2.js"]
var mods_included = mods_to_include.map(mod => enabledMods.includes(mod));
var all_mods_included = mods_included.reduce(function(a,b) { return a && b });

View File

@ -6,14 +6,15 @@ var lightmapWidth, lightmapHeight;
var lightmapScale = 2;
var lightSourceBoost = 2;
var pixelSizeQuarter = pixelSizeHalf / 2;
var falloff = 0.8;
// BetterSettings.js integration
var lightmap_settingsTab = new SettingsTab("Lightmap");
var resolution_setting = new Setting("Resolution (higher number = lower quality)", "resolution", settingType.NUMBER, false, defaultValue=2);
var falloff_setting = new Setting("Falloff (higher number = higher blur radius)", "falloff", settingType.NUMBER, false, defaultValue=0.8);
lightmap_settingsTab.registerSettings("Resolution", resolution_setting);
lightmap_settingsTab.registerSettings("Falloff", falloff_setting);
settingsManager.registerTab(lightmap_settingsTab);
@ -90,6 +91,7 @@ function propagateLightmap() {
var width = lightmap[0].length;
var height = lightmap.length;
var falloff = falloff_setting.value;
var neighbors = [
{ dx: 1, dy: 0 },
{ dx: -1, dy: 0 },
@ -313,6 +315,12 @@ elements.fire.tick = function(pixel) {
glowItsOwnColor(pixel);
};
var originalColdFireTick2 = elements.cold_fire.tick;
elements.cold_fire.tick = function(pixel) {
originalColdFireTick2(pixel);
glowItsOwnColor(pixel);
};
var originalFlashTick = elements.flash.tick;
elements.flash.tick = function(pixel) {
originalFlashTick(pixel);
@ -354,7 +362,6 @@ elements.sun.tick = glowItsOwnColor;
elements.magma.tick = glowItsOwnColor;
elements.plasma.tick = glowItsOwnColor;
elements.fw_ember.tick = glowItsOwnColor;
elements.cold_fire.tick = glowItsOwnColor;
var radioactiveElements = [
"uranium", "radiation", "rad_glass", "fallout",

View File

@ -68,14 +68,4 @@ elements.maze = {
generateMaze(mouseSize - 1, mouseSize - 1, Math.floor(mousePos.x - mouseSize / 2) + 1, Math.floor(mousePos.y - mouseSize / 2) + 1)
}
}
runAfterLoadList.push(() => {
if (!enabledMods.includes("mods/editTools.js")) {
document.addEventListener("mousedown", (ev) => {
if (elements[currentElement].onMouseDown) {
elements[currentElement].onMouseDown();
}
})
}
})
}

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +1,47 @@
// Sky.js
// BetterSettings.js integration
if (!enabledMods.includes("mods/betterSettings.js")) { enabledMods.unshift("mods/betterSettings.js"); localStorage.setItem("enabledMods", JSON.stringify(enabledMods)); window.location.reload() };
var sky_settingsTab = new SettingsTab("Sky");
var realtime_setting = new Setting("Use real life time for sky", "real_time", settingType.BOOLEAN, false, defaultValue=false);
var initial_hour_setting = new Setting("Initial hour", "initial_hour", settingType.NUMBER, false, defaultValue=8);
var ticks_per_hour_setting = new Setting("Ticks per hour", "ticks_per_hour", settingType.NUMBER, false, defaultValue=150);
var ticks_per_hour_setting = new Setting("Ticks per hour", "ticks_per_hour", settingType.NUMBER, false, defaultValue=300);
var airtemp_setting = new Setting("Change air temperature based on time", "air_temp", settingType.BOOLEAN, false, defaultValue=true);
var drawSun = new Setting("Add sun", "drawSun", settingType.BOOLEAN, false, defaultValue=true);
sky_settingsTab.registerSettings("Real time", realtime_setting);
sky_settingsTab.registerSettings("Initial hour", initial_hour_setting);
sky_settingsTab.registerSettings("Ticks per hour", ticks_per_hour_setting);
sky_settingsTab.registerSettings("Temperature", airtemp_setting);
sky_settingsTab.registerSettings("Sun", drawSun);
settingsManager.registerTab(sky_settingsTab);
//function lerpColor(start, end, t) {
// return start.map((s, i) => Math.round(s + (end[i] - s) * t));
//}
// Destructuring makes it faster
function lerpColor([r1, g1, b1], [r2, g2, b2], t) {
return [r1 + (r2 - r1) * t, g1 + (g2 - g1) * t, b1 + (b2 - b1) * t].map(Math.round);
}
function hourToTemp(hour, Tmin=10, Tmax=30) {
return Tmin + (Tmax - Tmin) * Math.pow(Math.sin((Math.PI / 24) * (hour - 4)), 2);
}
function getSunPositionInRect(x_, y_, w, h) {
// Convert hour to angle
var angle = Math.PI * (18 - hour) / 12;
// Convert angle to position
var centerX = x_ + (w / 2);
var centerY = y_ + h;
var radius = (w) / 2;
var x = centerX + radius * Math.cos(angle);
var y = centerY - radius * Math.sin(angle);
return { angle, x, y };
}
function getSkyColors(hour) {
const SKY_COLOR_PAIRS = [
[[0, 0, 15], [0, 0, 30]], // midnight
@ -46,15 +68,38 @@ function getSkyColors(hour) {
};
}
function renderSky(ctx) {
function drawSunSquare(ctx, sunPos, size, color, blur) {
ctx.save();
ctx.filter = `blur(${blur}px)`;
ctx.translate(sunPos.x * pixelSize, sunPos.y * pixelSize);
ctx.rotate(sunPos.angle);
ctx.fillStyle = color;
ctx.fillRect(-size * 0.5, -size * 0.5, size, size);
ctx.restore();
}
function renderSkyAndSun(ctx) {
// Get sky colors and make gradient
const { skyTop, skyBottom } = getSkyColors(hour);
const gradient = ctx.createLinearGradient(0, 0, 0, height * pixelSize);
gradient.addColorStop(0, skyTop);
gradient.addColorStop(1, skyBottom);
ctx.globalAlpha = 1.0;
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, (width + 1) * pixelSize, (height + 1) * pixelSize);
// Draw sun
if (hour < 5.5 || hour > 18.5) {return;}
if (!drawSun.value) {return;}
var sunPos = getSunPositionInRect(width * 0.1, height * 0.1, width * 0.8, height * 0.9);
var sunSize = pixelSize * 9;
var nearSunSetOrRise = Math.pow((1 - Math.cos((Math.PI / 6) * hour)) / 2, 4);
var color = RGBToHex(lerpColor([255, 230, 225], [255, 160, 128], nearSunSetOrRise));
drawSunSquare(ctx, sunPos, sunSize, color, 5); // Glow
drawSunSquare(ctx, sunPos, sunSize * 0.75, "#FFFFFF", 1);
}
function updateDayTime() {
@ -64,28 +109,33 @@ function updateDayTime() {
const now = new Date();
hour = now.getHours() + now.getMinutes() / 60;
} else {
hour = (hour + (1 / ticks_per_hour_setting.value)) % 24; // Keep within 0-23
var hours_per_tick = 1 / (ticks_per_hour_setting.value + 1);
hour = (hour + hours_per_tick) % 24; // Keep within 0-23
}
if (airtemp_setting.value) {
airTemp = hourToTemp(hour, 12, 26);
}
}
// Sky should be first layer
function prioritizeRenderSky() {
const idx = renderPrePixelList.indexOf(renderSky);
function prioritizeSky() {
const idx = renderPrePixelList.indexOf(renderSkyAndSun);
if (idx !== -1) {
const [skyFn] = renderPrePixelList.splice(idx, 1);
renderPrePixelList.unshift(skyFn);
}
}
// Resetting canvas also resets time
// Resetting canvas also resets hour
function initializeSky() {
hour = initial_hour_setting.value;
}
// Hooks
runAfterReset(initializeSky);
runAfterLoad(prioritizeRenderSky);
runAfterLoad(prioritizeSky);
runEveryTick(updateDayTime);
renderPrePixel(renderSky);
renderPrePixel(renderSkyAndSun);
var hour = initial_hour_setting.value;