bettermetalscrap.js
This commit is contained in:
parent
82d62b9fcc
commit
434dcac372
|
|
@ -156,6 +156,7 @@
|
||||||
<tr><td>alcohol.js</td><td>Adds methanol, (iso-)propanol, and butanol</td><td>Alice</td></tr>
|
<tr><td>alcohol.js</td><td>Adds methanol, (iso-)propanol, and butanol</td><td>Alice</td></tr>
|
||||||
<tr><td>alkahest.js</td><td>Adds the alkahest, a liquid which dissolves anything</td><td>Alice</td></tr>
|
<tr><td>alkahest.js</td><td>Adds the alkahest, a liquid which dissolves anything</td><td>Alice</td></tr>
|
||||||
<tr><td>aScientistsWish.js</td><td>Adds things that related to science, especially radiation</td><td>Carbon Monoxide, CPU</td></tr>
|
<tr><td>aScientistsWish.js</td><td>Adds things that related to science, especially radiation</td><td>Carbon Monoxide, CPU</td></tr>
|
||||||
|
<tr><td>bettermetalscrap.js</td><td>Allows metal scrap to be melted back into its original material</td><td>nousernamefound</td></tr>
|
||||||
<tr><td>bigger_star_spawners.js</td><td>Adds spawners for larger stars</td><td>Alice</td></tr>
|
<tr><td>bigger_star_spawners.js</td><td>Adds spawners for larger stars</td><td>Alice</td></tr>
|
||||||
<tr><td>bioooze_and_pyrogens.js</td><td>Adds Bio-Ooze from <a herf="https://frackinuniverse.miraheze.org/wiki/Main_Page">Frackin’ Universe</a> and several heat-producing materials from various games’ mods</td><td>Alice</td></tr>
|
<tr><td>bioooze_and_pyrogens.js</td><td>Adds Bio-Ooze from <a herf="https://frackinuniverse.miraheze.org/wiki/Main_Page">Frackin’ Universe</a> and several heat-producing materials from various games’ mods</td><td>Alice</td></tr>
|
||||||
<tr><td>boiling_things.js</td><td>Allows for various elements to be vaporized</td><td>Alice</td></tr>
|
<tr><td>boiling_things.js</td><td>Allows for various elements to be vaporized</td><td>Alice</td></tr>
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,6 +9,12 @@ for (let elementi in elements){
|
||||||
biologicaltocorrode.splice(biologicaltocorrode.indexOf("salt"), 1)
|
biologicaltocorrode.splice(biologicaltocorrode.indexOf("salt"), 1)
|
||||||
biologicaltocorrode.splice(biologicaltocorrode.indexOf("sugar"), 1)
|
biologicaltocorrode.splice(biologicaltocorrode.indexOf("sugar"), 1)
|
||||||
biologicaltocorrode.push("wood")
|
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){
|
function basicHalogen(pixel){
|
||||||
for (var i = 0; i < adjacentCoords.length; i++) {
|
for (var i = 0; i < adjacentCoords.length; i++) {
|
||||||
var coord = adjacentCoords[i];
|
var coord = adjacentCoords[i];
|
||||||
|
|
|
||||||
|
|
@ -2,32 +2,41 @@ function weightedAverage(num1, num2, weight){
|
||||||
return ((weight * num1)+((1-weight)*num2))
|
return ((weight * num1)+((1-weight)*num2))
|
||||||
}
|
}
|
||||||
const heatfunc = function(pixel){
|
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.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.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.ogB = parseInt(pixel.color.slice(pixel.color.lastIndexOf(',') + 1, -1), 10)
|
||||||
pixel.ogElement = pixel.element
|
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)
|
var halftemp = ((20+gethigh)/2)
|
||||||
if (pixel.temp <= (gethigh) - halftemp){
|
if (pixel.temp <= (gethigh) - halftemp){
|
||||||
var ctemp = 0;
|
ctemp = 0;
|
||||||
} else if (pixel.temp > (gethigh)-halftemp && pixel.temp <= gethigh){
|
} 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){
|
if (ctemp <= 0.5){
|
||||||
var newR = (((510-(2*pixel.ogR))*ctemp)+pixel.ogR);
|
newR = (((510-(2*pixel.ogR))*ctemp)+pixel.ogR);
|
||||||
var newG = ((0-((2*pixel.ogG)*ctemp))+pixel.ogG);
|
newG = ((0-((2*pixel.ogG)*ctemp))+pixel.ogG);
|
||||||
var newB = ((0-((2*pixel.ogB)*ctemp))+pixel.ogB);
|
newB = ((0-((2*pixel.ogB)*ctemp))+pixel.ogB);
|
||||||
}else if (ctemp > 0.5){
|
}else if (ctemp > 0.5){
|
||||||
var newR = 255;
|
newR = 255;
|
||||||
var newG = ((510*ctemp)-255);
|
newG = ((510*ctemp)-255);
|
||||||
var newB= ((280*ctemp)-140);
|
newB= ((280*ctemp)-140);
|
||||||
}
|
}
|
||||||
let weight = (1-(ctemp/1.3))
|
let weight = (1-(ctemp/1.3))
|
||||||
pixel.color = "rgb(" + weightedAverage(pixel.ogR, newR, weight) + "," + weightedAverage(pixel.ogG, newG, weight) + "," + weightedAverage(pixel.ogB, newB, weight) + ")";
|
pixel.color = "rgb(" + weightedAverage(pixel.ogR, newR, weight) + "," + weightedAverage(pixel.ogG, newG, weight) + "," + weightedAverage(pixel.ogB, newB, weight) + ")";
|
||||||
}
|
}}};
|
||||||
};
|
|
||||||
if (!eLists.metals) { eLists.metals = [] }
|
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 = 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 => {
|
eLists.metals.forEach(metal => {
|
||||||
|
|
@ -36,8 +45,8 @@ eLists.metals.forEach(metal => {
|
||||||
elements[metal].tick = heatfunc;
|
elements[metal].tick = heatfunc;
|
||||||
}else{
|
}else{
|
||||||
const modfunc = function(pixel){
|
const modfunc = function(pixel){
|
||||||
prefunc(pixel);
|
|
||||||
heatfunc(pixel);
|
heatfunc(pixel);
|
||||||
|
prefunc(pixel);
|
||||||
};
|
};
|
||||||
elements[metal].tick = modfunc;
|
elements[metal].tick = modfunc;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue