diff --git a/mod-list.html b/mod-list.html
index a383129d..f07335c9 100644
--- a/mod-list.html
+++ b/mod-list.html
@@ -156,6 +156,7 @@
| alcohol.js | Adds methanol, (iso-)propanol, and butanol | Alice |
| alkahest.js | Adds the alkahest, a liquid which dissolves anything | Alice |
| aScientistsWish.js | Adds things that related to science, especially radiation | Carbon Monoxide, CPU |
+| bettermetalscrap.js | Allows metal scrap to be melted back into its original material | nousernamefound |
| bigger_star_spawners.js | Adds spawners for larger stars | Alice |
| bioooze_and_pyrogens.js | Adds Bio-Ooze from Frackin’ Universe and several heat-producing materials from various games’ mods | Alice |
| boiling_things.js | Allows for various elements to be vaporized | Alice |
diff --git a/mods/bettermetalscrap.js b/mods/bettermetalscrap.js
new file mode 100644
index 00000000..d4f34e85
--- /dev/null
+++ b/mods/bettermetalscrap.js
@@ -0,0 +1,37 @@
+if (!elements.aluminum.properties){elements.aluminum.properties = {}}
+elements.aluminum.properties.scrapType = "aluminum"
+if (!elements.tin.properties){elements.tin.properties = {}}
+elements.tin.properties.scrapType = "tin"
+if (!elements.brass.properties){elements.brass.properties = {}}
+elements.brass.properties.scrapType = "brass"
+if (!elements.grenade.properties){elements.grenade.properties = {}}
+elements.grenade.properties.scrapType = "steel"
+if (!elements.smoke_grenade.properties){elements.smoke_grenade.properties = {}}
+elements.smoke_grenade.properties.scrapType = "steel"
+if (!elements.flashbang.properties){elements.flashbang.properties = {}}
+elements.flashbang.properties.scrapType = "steel"
+var randomScrap = ["aluminum", "steel", "iron"]
+delete elements.metal_scrap.tempHigh
+delete elements.metal_scrap.stateHigh
+if (!elements.metal_scrap.tick){
+elements.metal_scrap.tick = function(pixel){
+ if (!pixel.scrapType){
+ pixel.scrapType = randomScrap[Math.floor(Math.random()*randomScrap.length)]
+ }
+ if (pixel.temp >= elements[pixel.scrapType].tempHigh){
+ changePixel(pixel, pixel.scrapType, false)
+ }
+}
+}
+else {
+ const prefunc = elements.metal_scrap.tick;
+ elements.metal_scrap.tick = function(pixel){
+ prefunc(pixel);
+ if (!pixel.scrapType){
+ pixel.scrapType = randomScrap[Math.floor(Math.random()*randomScrap.length)]
+ }
+ if (pixel.temp >= elements[pixel.scrapType].tempHigh){
+ changePixel(pixel, pixel.scrapType, false)
+ }
+ }
+}
\ No newline at end of file
diff --git a/mods/halogen.js b/mods/halogen.js
index 254197dd..a63b5ac3 100644
--- a/mods/halogen.js
+++ b/mods/halogen.js
@@ -9,6 +9,12 @@ for (let elementi in elements){
biologicaltocorrode.splice(biologicaltocorrode.indexOf("salt"), 1)
biologicaltocorrode.splice(biologicaltocorrode.indexOf("sugar"), 1)
biologicaltocorrode.push("wood")
+if (enabledMods.includes("mods/bettermetalscrap.js")){
+ for (let metal in metalstocorrode){
+ if (!elements[metalstocorrode[metal]].properties){elements[metalstocorrode[metal]].properties = {}}
+ elements[metalstocorrode[metal]].properties.scrapType = metalstocorrode[metal]
+ }
+}
function basicHalogen(pixel){
for (var i = 0; i < adjacentCoords.length; i++) {
var coord = adjacentCoords[i];
diff --git a/mods/heatglow.js b/mods/heatglow.js
index 568d58fd..8c8dabc0 100644
--- a/mods/heatglow.js
+++ b/mods/heatglow.js
@@ -2,32 +2,41 @@ function weightedAverage(num1, num2, weight){
return ((weight * num1)+((1-weight)*num2))
}
const heatfunc = function(pixel){
- if (pixel.ogR == null || pixel.ogG == null || pixel.ogB == null || !(pixel.element == pixel.ogElement)){
+ if (pixel.element != "metal_scrap" || eLists.metals.includes(pixel.scrapType) || !pixel.scrapType){{
+ if (pixel.ogR == null || pixel.ogG == null || pixel.ogB == null || (pixel.element != pixel.ogElement && pixel.element == "metal_scrap") || (pixel.element != "metal_scrap" && pixel.ogElement == "metal_scrap")){
pixel.ogR = parseInt(pixel.color.slice(4, pixel.color.indexOf(',')), 10)
pixel.ogG = parseInt(pixel.color.slice(pixel.color.indexOf(',') + 1, pixel.color.lastIndexOf(',')), 10)
pixel.ogB = parseInt(pixel.color.slice(pixel.color.lastIndexOf(',') + 1, -1), 10)
pixel.ogElement = pixel.element
- }else{
- var gethigh = (elements[pixel.element].tempHigh)
+ }
+ var gethigh = 1000
+ var ctemp = 0
+ var ogR = 0
+ var ogG = 0
+ var ogB = 0
+ if (elements[pixel.element].tempHigh){
+ gethigh = elements[pixel.element].tempHigh
+ } else if (pixel.scrapType) {
+ gethigh = elements[pixel.scrapType].tempHigh
+ }
var halftemp = ((20+gethigh)/2)
if (pixel.temp <= (gethigh) - halftemp){
- var ctemp = 0;
+ ctemp = 0;
} else if (pixel.temp > (gethigh)-halftemp && pixel.temp <= gethigh){
- var ctemp = ((1/halftemp)*pixel.temp)-(((gethigh)-halftemp)/halftemp)
+ ctemp = ((1/halftemp)*pixel.temp)-(((gethigh)-halftemp)/halftemp)
}
if (ctemp <= 0.5){
- var newR = (((510-(2*pixel.ogR))*ctemp)+pixel.ogR);
- var newG = ((0-((2*pixel.ogG)*ctemp))+pixel.ogG);
- var newB = ((0-((2*pixel.ogB)*ctemp))+pixel.ogB);
+ newR = (((510-(2*pixel.ogR))*ctemp)+pixel.ogR);
+ newG = ((0-((2*pixel.ogG)*ctemp))+pixel.ogG);
+ newB = ((0-((2*pixel.ogB)*ctemp))+pixel.ogB);
}else if (ctemp > 0.5){
- var newR = 255;
- var newG = ((510*ctemp)-255);
- var newB= ((280*ctemp)-140);
+ newR = 255;
+ newG = ((510*ctemp)-255);
+ newB= ((280*ctemp)-140);
}
let weight = (1-(ctemp/1.3))
pixel.color = "rgb(" + weightedAverage(pixel.ogR, newR, weight) + "," + weightedAverage(pixel.ogG, newG, weight) + "," + weightedAverage(pixel.ogB, newB, weight) + ")";
- }
- };
+ }}};
if (!eLists.metals) { eLists.metals = [] }
eLists.metals = eLists.metals.concat(["iron", "glass", "copper", "gold", "brass","steel","nickel","zinc","silver","aluminum","bronze","metal_scrap","oxidized_copper","tin","lead", "rose_gold"])
eLists.metals.forEach(metal => {
@@ -36,8 +45,8 @@ eLists.metals.forEach(metal => {
elements[metal].tick = heatfunc;
}else{
const modfunc = function(pixel){
- prefunc(pixel);
heatfunc(pixel);
+ prefunc(pixel);
};
elements[metal].tick = modfunc;
}