diff --git a/index.html b/index.html index 67c13993..1f33f15b 100644 --- a/index.html +++ b/index.html @@ -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); } diff --git a/mods/WhisperingTheory.js b/mods/WhisperingTheory.js new file mode 100644 index 00000000..ad41280b --- /dev/null +++ b/mods/WhisperingTheory.js @@ -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", +] diff --git a/mods/betterMenuScreens.js b/mods/betterMenuScreens.js index dc18861c..d150d814 100644 --- a/mods/betterMenuScreens.js +++ b/mods/betterMenuScreens.js @@ -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; diff --git a/mods/betterSettings.js b/mods/betterSettings.js index 811946a7..bb213cc0 100644 --- a/mods/betterSettings.js +++ b/mods/betterSettings.js @@ -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) { diff --git a/mods/electricityTest.js b/mods/electricityTest.js new file mode 100644 index 00000000..de4b87fb --- /dev/null +++ b/mods/electricityTest.js @@ -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); + } + } + } +} \ No newline at end of file diff --git a/mods/elementsManager.js b/mods/elementsManager.js index 74cdbee9..23ac1dd0 100644 --- a/mods/elementsManager.js +++ b/mods/elementsManager.js @@ -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; diff --git a/mods/moreViews.js b/mods/moreViews.js index 1d874d60..c2c18f67 100644 --- a/mods/moreViews.js +++ b/mods/moreViews.js @@ -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); }) diff --git a/mods/nousersthings.js b/mods/nousersthings.js index 7164924c..006af6b3 100644 --- a/mods/nousersthings.js +++ b/mods/nousersthings.js @@ -2343,4 +2343,28 @@ elements.scuffed_circle_brush = { deletePixel(thisx, thisy) createPixel(circleElem, thisx, thisy) } -} \ No newline at end of file +} +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") \ No newline at end of file diff --git a/mods/video.js b/mods/video.js index ce21ee24..2a75e490 100644 --- a/mods/video.js +++ b/mods/video.js @@ -89,6 +89,7 @@ elements.video = { } }; + currentVideoFrames = []; video.currentTime = 0; video.onseeked = () => {