Merge branch 'R74nCom:main' into main

This commit is contained in:
SquareScreamYT 2024-03-22 08:19:20 +08:00 committed by GitHub
commit 42c69ff3d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 172 additions and 15 deletions

View File

@ -9960,6 +9960,7 @@
else { changePixel(pixel, elem2); }
}
if (r.func) { r.func(pixel,pixel) }
if (r.color2) { pixel.color = pixelColorPick(pixel,r.color2) }
}
},
ignore: ["sun"],
@ -15520,7 +15521,7 @@ window.onload = function() {
return elements[e].excludeRandom != true && elements[e].category != "tools" && !elements[e].tool;
});
gameCanvas.addEventListener("mousedown", mouseClick);
gameCanvas.addEventListener("mousedown", function(){
gameCanvas.addEventListener("mousedown", function(e){
if (elements[currentElement] && elements[currentElement].onMouseDown) {
elements[currentElement].onMouseDown(e);
}

83
mods/WhisperingTheory.js Normal file
View File

@ -0,0 +1,83 @@
/* TODO
- [x] powder heater & coller
- [x] block roomtemp
- [x] no smoke from cold fire
*/
elements.powder_heater = {
category: "machines",
behavior: [
"XX|HT:2|XX",
"HT:2|XX|HT:2",
"M2|HT:2 AND M1|M2",
],
color: "#881111",
insulate: true,
};
elements.powder_cooler = {
category: "machines",
behavior: [
"XX|CO:2|XX",
"CO:2|XX|CO:2",
"M2|CO:2 AND M1|M2",
],
color: "#111188",
insulate: true,
};
elements.powder_superheater = {
category: "machines",
behavior: [
"XX|HT:10|XX",
"HT:10|XX|HT:10",
"M2|HT:10 AND M1|M2",
],
color: "#dd1111",
insulate: true,
};
elements.powder_freeze = {
category: "machines",
behavior: [
"XX|CO:10|XX",
"CO:10|XX|CO:10",
"M2|CO:10 AND M1|M2",
],
color: "#1111dd",
insulate: true,
};
elements.roomtemper = {
color: "#29632f",
behavior: behaviors.WALL,
tick: function(pixel) {
for (var i = 0; i < squareCoords.length; i++) {
var coord = squareCoords[i];
var x = pixel.x+coord[0];
var y = pixel.y+coord[1];
if (!isEmpty(x,y, true)) {
if(pixelMap[x][y].temp < -230) {
pixelMap[x][y].temp = (pixelMap[x][y].temp + 7)
} else if(pixelMap[x][y].temp > 270) {
pixelMap[x][y].temp = (pixelMap[x][y].temp - 7)
} else if (pixelMap[x][y].temp < 20) {
pixelMap[x][y].temp = (pixelMap[x][y].temp + 2)
} else if (pixelMap[x][y].temp > 20) {
pixelMap[x][y].temp = (pixelMap[x][y].temp - 2)
}
}
}
},
category:"machines",
state:"solid",
insulate: true,
noMix: true,
movable: false,
},
elements.cold_fire.behavior = [
"M1|M1|M1",
"M2|DL%8|M2",
"XX|M2|XX",
]

View File

@ -153,7 +153,7 @@ class MenuScreen {
/**
* Sets close button visibility. When false the close button will not be added to the menu screen
* @param {boolean} show Visibility of the close button
* @param {boolean} show Visibility of the close g button
*/
setShowCloseButton(show) {
this.showCloseButton = show;

View File

@ -6,16 +6,19 @@ const settingType = {
SELECT: [4, null]
}
class Setting {
constructor (name, storageName, type, disabled = false, defaultValue = null) {
constructor (name, storageName, type, disabled = false, defaultValue = null, description = "", customValidator = () => true) {
this.tabName = null;
this.name = name;
this.storageName = storageName;
this.type = type[0];
this.disabled = disabled;
this.defaultValue = defaultValue ?? type[1];
this.description = description;
this.validate = customValidator;
}
set(value) {
if (!this.validate(value)) return false;
this.value = value;
const settings = JSON.parse(localStorage.getItem(`${this.tabName}/settings`)) ?? {};
settings[this.name] = value;
@ -61,7 +64,7 @@ class Setting {
const id = "betterSettings/" + this.modName + "/" + this.storageName;
const span = document.createElement("span");
span.className = "setting-span";
span.title = 'Default: "' + this.defaultValue + '"' + (this.disabled ? ". This setting is disabled." : "");
span.title = 'Default: "' + this.defaultValue + '"' + (this.disabled ? ". This setting is disabled" : "") + (this.description ? `. ${this.description}` : "");
span.innerText = this.name + " ";
const element = document.createElement("input");
switch (this.type) {
@ -162,12 +165,14 @@ class SettingsTab {
if (this.categories.has(category)) this.categories.get(category).push(setting);
else this.categories.set(category, [setting]);
this.registry.set(setting.storageName, setting);
return this;
}
registerSettings(category = "General", ...settings) {
for (const setting of settings) {
this.registerSetting(setting, category);
}
return this;
}
set(name, value) {

42
mods/electricityTest.js Normal file
View File

@ -0,0 +1,42 @@
doElectricity = function (pixel) {
if (pixel.charge) {
// Check each adjacent pixel, if that pixel's charge is false, set it to the same charge
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,true)) {
var newPixel = pixelMap[x][y];
var con = elements[newPixel.element].conduct;
if (con == undefined) {continue}
if (Math.random() < con) { // If random number is less than conductivity
if (!newPixel.charge && !newPixel.chargeCD) {
newPixel.charge = 1;
if (elements[newPixel.element].colorOn) {
newPixel.color = pixelColorPick(newPixel);
}
}
}
else if (elements[newPixel.element].insulate != true) { // Otherwise heat the pixel (Resistance simulation)
newPixel.temp += pixel.charge/4;
if (con < 0.8) { newPixel.chargeCD = 8; }
pixelTempCheck(newPixel);
}
}
}
pixel.charge -= 0.25;
if (pixel.charge <= 0) {
delete pixel.charge;
pixel.chargeCD = 4;
}
}
// Lower charge cooldown
else if (pixel.chargeCD) {
pixel.chargeCD -= 1;
if (pixel.chargeCD <= 0) {
delete pixel.chargeCD;
if (elements[pixel.element].colorOn) {
pixel.color = pixelColorPick(pixel);
}
}
}
}

View File

@ -257,7 +257,7 @@ if (enabledMods.includes("mods/betterMenuScreens.js")) {
// ugly way of doing it but probably works
const checkType = (key, value) => {
if (key == "behavior" && (typeof value == "function" || (value instanceof Array && value.filter(e => e instanceof Array && e.filter(s => typeof s == "string").length == e.length).length == value.length))) return true;
if (key == "behavior" && (typeof value == "function" || (value instanceof Array && value.filter(e => typeof e == "string").length == value.length))) return true;
else if (key == "behavior") return false;
if (["darkText", "hidden", "insulate", "noMix", "isFood", "forceAutoGen", "customColor", "ignoreAir", "excludeRandom", "burning", "flipX", "flipY", "flippableX", "flippableY"].includes(key) && typeof value != "boolean") return false;
if (["name", "category", "desc", "alias", "seed", "baby", "state", "stateHigh", "stateHighName", "stateHighColor", "stateLow", "stateLowNmae", "stateLowColor"].includes(key) && typeof value != "string") return false;

View File

@ -34,18 +34,19 @@ setView = (n) => {
document.querySelector('span[setting="view"]').children[0].value = view ?? 0;
}
for (const i in views) {
if (i < 4) continue;
const option = document.createElement("option");
option.setAttribute("value", i);
option.innerText = views[i];
document.querySelector('.setting-span[setting="view"]').querySelector("select").appendChild(option);
viewKey[i] = views[i];
}
runAfterLoadList.push(() => {
for (const i in views) {
if (i < 4) continue;
const option = document.createElement("option");
option.setAttribute("value", i);
option.innerText = views[i];
document.querySelector('.setting-span[setting="view"]').querySelector("select").appendChild(option);
viewKey[i] = views[i];
}
})
const vcrFont = new FontFace("VCR", "url(mods/VCR_OSD_MONO.ttf)");
vcrFont.load().then(font => {
console.log(font);
document.fonts.add(font);
})

View File

@ -2343,4 +2343,28 @@ elements.scuffed_circle_brush = {
deletePixel(thisx, thisy)
createPixel(circleElem, thisx, thisy)
}
}
}
elements.spacedust_cola = {
color: ["#090033", "#0a0027", "#0a001b", "#0b000f"],
behavior: elements.soda.behavior,
tempHigh: 104,
stateHigh: ["steam", "carbon_dioxide", "spacedust", "spacedust"],
category: "liquids",
state: "liquid",
reactions: {head: {elem1: null, chance: 0.02}},
density: elements.tungsten.density,
}
elements.spacedust = {
color: ["#090033", "#0a0027", "#0a001b", "#0b000f", "#090033", "#0a0027", "#0a001b", "#0b000f", "#090033", "#0a0027", "#0a001b", "#0b000f", "#090033", "#0a0027", "#0a001b", "#0b000f", "#090033", "#0a0027", "#0a001b", "#0b000f", "#090033", "#0a0027", "#0a001b", "#0b000f", "#ffffff"],
behavior: behaviors.POWDER,
category: "special",
state: "solid",
reactions: {
"acid": {elem1: null, elem2: ["hydrogen", "helium", "hydrogen", "helium", "hydrogen", "helium", "hydrogen", "hydrogen", "hydrogen", "hydrogen", "metal_scrap"], chance: 0.02},
"seltzer": {elem1: null, elem2: "spacedust_cola"},
"soda": {elem1: null, elem2: "spacedust_cola"},
},
density: elements.tungsten.density,
}
elements.acid.ignore.push("spacedust")
elements.acid.ignore.push("spacedust_cola")

View File

@ -89,6 +89,7 @@ elements.video = {
}
};
currentVideoFrames = [];
video.currentTime = 0;
video.onseeked = () => {