diff --git a/mod-list.html b/mod-list.html index 6777ef38..bbe0402d 100644 --- a/mod-list.html +++ b/mod-list.html @@ -131,6 +131,7 @@ Official alchemy.jsStart with only 4 elements and unlock more by reacting them together (Most are not possible)R74n +background_changer.jsPress 'B' to change canvas background to a URLR74n building.jsBuilding generators and materialsR74n classic_explosives.jsRe-adds 4 explosives removed in v1.9.3R74n classic_textures.jsUse textures from early versions of the gameR74n diff --git a/mods/background_changer.js b/mods/background_changer.js new file mode 100644 index 00000000..200daa97 --- /dev/null +++ b/mods/background_changer.js @@ -0,0 +1,40 @@ +function setCanvasBG(url) { + delete settings.bg; + + let canvas = document.getElementById("game"); + canvas.style.backgroundColor = ""; + canvas.style.backgroundImage = `url(${url})`; + canvas.style.backgroundRepeat = "no-repeat"; + canvas.style.backgroundSize = "cover"; + canvas.style.backgroundPosition = "bottom"; + + settings.bgimg = url; + + saveSettings() +} + +keybinds.KeyB = () => { + promptInput("Enter an image URL. Leave blank to clear background.", (url) => { + if (!url) { + delete settings.bgimg; + let canvas = document.getElementById("game"); + canvas.style.backgroundImage = ""; + canvas.style.backgroundRepeat = ""; + canvas.style.backgroundSize = ""; + canvas.style.backgroundPosition = ""; + } + setCanvasBG(url); + }, "Background") +} + +document.addEventListener("load", () => { + if (settings.bgimg) { + setCanvasBG(settings.bgimg) + } +}) + +runAfterReset(() => { + if (settings.bgimg) { + setCanvasBG(settings.bgimg) + } +}) \ No newline at end of file