var modName = "mods/random_rocks.js"; var libraryMod = "mods/code_library.js"; if(enabledMods.includes(libraryMod)) { /* elements.iron.reactions.radiation = {elem1: 'dirty_water', elem2: null} when radiation touches iron, the iron turns into dirty_water (elem1) and the radiation deletes itself (elem2) elements.AAA.reactions.BBB: {elem1: CCC, elem2: DDD} when BBB touches AAA, the AAA becomes CCC and the BBB becomes DDD */ // imaginary reaction elements.iron.reactions.test //Variable fireSpawnBlacklist = ["fire","cold_fire","rad_fire"]; //doBurning function doBurning(pixel) { if (pixel.burning) { // Burning var info = elements[pixel.element]; var burnTempChange = info.burnTempChange if (burnTempChange == undefined) { burnTempChange = 1; }; //move fire ahead so that cold burners don't light hot burners var fireIsCold; //Fire getter block var fire = info.fireElement; if (fire == undefined) { fire = 'fire'; } else if(fire instanceof Array) { fire = fire[Math.floor(Math.random()*fire.length)]; } //End fire getter block //Fire temp getter block var fireTemp = info.fireSpawnTemp; if (fireTemp == undefined) { fireTemp = pixel.temp; }; //End fire temp getter block //Fire chance getter block var fireChance = info.fireSpawnChance; if (fireChance == undefined) { fireChance = 10; }; //End fire chance getter block var fireIsCold = (fire === "cold_fire"); var fireInfo = elements[fire]; pixel.temp += burnTempChange; pixelTempCheck(pixel); for (var i = 0; i < adjacentCoords.length; i++) { // Burn adjacent pixels 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 newInfo = elements[newPixel.element]; var newFireIsCold; //Fire getter block var newFire = newInfo.fireElement; if (newFire == undefined) { newFire = 'fire'; } else if(newFire instanceof Array) { newFire = newFire[Math.floor(Math.random()*newFire.length)]; } //End fire getter block newFireIsCold = (newFire === "cold_fire"); //console.log(`burning pixel ${pixel.element}: ${fire} (${fireIsCold}) / burned element ${newPixel.element}: ${newFire} (${newFireIsCold})`); if((!fireIsCold && !newFireIsCold) || (fireIsCold && newFireIsCold)) { if (elements[newPixel.element].burn && !newPixel.burning) { if (Math.floor(Math.random()*100) < elements[newPixel.element].burn) { newPixel.burning = true; newPixel.burnStart = pixelTicks; } } } } } if ((pixelTicks - pixel.burnStart > (info.burnTime || 200)) && Math.floor(Math.random()*100)<(info.burn || 10)) { var burnInto = info.burnInto; if (burnInto == undefined) { burnInto = 'fire'; } else if (burnInto instanceof Array) { burnInto = burnInto[Math.floor(Math.random()*burnInto.length)]; } changePixel(pixel,burnInto,(burnInto !== "smoke")); if (info.fireColor != undefined && burnInto == "fire") { pixel.color = pixelColorPick(pixel,info.fireColor); } else { pixel.color = pixelColorPick(pixel) } } else if (Math.floor(Math.random()*100)