Merge pull request #138 from lllllllllwith10ls/load_order_fix

hopefully this works
This commit is contained in:
slweeb 2023-09-30 21:02:47 -04:00 committed by GitHub
commit 57a3da5304
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 217 additions and 54 deletions

View File

@ -1,16 +1,25 @@
function whenAvailable(name, callback) { function whenAvailable(names, callback) {
var interval = 10; // ms var interval = 10; // ms
window.setTimeout(function() { window.setTimeout(function() {
if (window[name]) { let bool = true;
for(let i = 0; i < names.length; i++)
{
if(!window[names[i]])
{
bool = false;
}
}
if (bool) {
callback(); callback();
} else { } else {
whenAvailable(name, callback); whenAvailable(names, callback);
} }
}, interval); }, interval);
} }
var runAfterAutogenMod = "mods/runAfterAutogen and onload restructure.js"; var runAfterAutogenMod = "mods/runAfterAutogen2.js";
if(enabledMods.includes(runAfterAutogenMod)){ if(enabledMods.includes(runAfterAutogenMod)){
whenAvailable("runAfterAutogen", function() { whenAvailable(["runAfterAutogen"], function() {
elements.fluorine = { elements.fluorine = {
color: "#FFFFBF", color: "#FFFFBF",
@ -411,9 +420,8 @@ trueAcidGases = ["acid_gas", "hydrofluoric_acid_gas"];
if (enabledMods.includes("mods/generative_mods.js")) { if (enabledMods.includes("mods/generative_mods.js")) {
runAfterLoad(function() { whenAvailable(["generateCloud"], function() {
generateCloud("hydrofluoric_acid"); generateCloud("hydrofluoric_acid");
});
elements["hydrofluoric_acid_gas"].reactions["hydrofluoric_acid_gas"]= { "elem1": null, "elem2": "hydrofluoric_acid_cloud", "chance":0.3, "y":[0,12], "setting":"clouds" }; elements["hydrofluoric_acid_gas"].reactions["hydrofluoric_acid_gas"]= { "elem1": null, "elem2": "hydrofluoric_acid_cloud", "chance":0.3, "y":[0,12], "setting":"clouds" };
elements["hydrofluoric_acid_gas"].reactions["rain_cloud"]= { "elem1": null, "elem2": "hydrofluoric_acid_cloud", "chance":0.4, "y":[0,12], "setting":"clouds" }; elements["hydrofluoric_acid_gas"].reactions["rain_cloud"]= { "elem1": null, "elem2": "hydrofluoric_acid_cloud", "chance":0.4, "y":[0,12], "setting":"clouds" };
elements["hydrofluoric_acid_gas"].reactions["cloud"]= { "elem1": null, "elem2": "hydrofluoric_acid_cloud", "chance":0.4, "y":[0,12], "setting":"clouds" }; elements["hydrofluoric_acid_gas"].reactions["cloud"]= { "elem1": null, "elem2": "hydrofluoric_acid_cloud", "chance":0.4, "y":[0,12], "setting":"clouds" };
@ -425,6 +433,7 @@ if (enabledMods.includes("mods/generative_mods.js")) {
elements["cloud"].reactions["anesthesia"] = { elem1:"nitric_acid_cloud", elem2:null, chance:0.05 }; elements["cloud"].reactions["anesthesia"] = { elem1:"nitric_acid_cloud", elem2:null, chance:0.05 };
elements["rain_cloud"].reactions["anesthesia"] = { elem1:"nitric_acid_cloud", elem2:null, chance:0.05 }; elements["rain_cloud"].reactions["anesthesia"] = { elem1:"nitric_acid_cloud", elem2:null, chance:0.05 };
});
} }
function createAcid(name,reactions, gasReactions, color, category, categoryGas, tempHigh, tempLowGas, tempLow, tempHighGas, density, densityGas) function createAcid(name,reactions, gasReactions, color, category, categoryGas, tempHigh, tempLowGas, tempLow, tempHighGas, density, densityGas)
{ {
@ -471,9 +480,8 @@ function createAcid(name,reactions, gasReactions, color, category, categoryGas,
elements.bless.reactions[name] = { elem2: "hydrogen" }; elements.bless.reactions[name] = { elem2: "hydrogen" };
elements.bless.reactions[name+"_gas"] = { elem2: "hydrogen" }; elements.bless.reactions[name+"_gas"] = { elem2: "hydrogen" };
if (enabledMods.includes("mods/generative_mods.js")) { if (enabledMods.includes("mods/generative_mods.js")) {
runAfterLoad(function() { whenAvailable(["generateCloud"], function() {
generateCloud(name); generateCloud(name);
});
elements[name+"_gas"].reactions[name+"_gas"]= { "elem1": null, "elem2": name + "_cloud", "chance":0.3, "y":[0,12], "setting":"clouds" }; elements[name+"_gas"].reactions[name+"_gas"]= { "elem1": null, "elem2": name + "_cloud", "chance":0.3, "y":[0,12], "setting":"clouds" };
elements[name+"_gas"].reactions["rain_cloud"]= { "elem1": null, "elem2": name + "_cloud", "chance":0.4, "y":[0,12], "setting":"clouds" }; elements[name+"_gas"].reactions["rain_cloud"]= { "elem1": null, "elem2": name + "_cloud", "chance":0.4, "y":[0,12], "setting":"clouds" };
elements[name+"_gas"].reactions["cloud"]= { "elem1": null, "elem2": name + "_cloud", "chance":0.4, "y":[0,12], "setting":"clouds" }; elements[name+"_gas"].reactions["cloud"]= { "elem1": null, "elem2": name + "_cloud", "chance":0.4, "y":[0,12], "setting":"clouds" };
@ -481,7 +489,8 @@ function createAcid(name,reactions, gasReactions, color, category, categoryGas,
elements[name+"_gas"].reactions["hail_cloud"]= { "elem1": null, "elem2": name + "_cloud", "chance":0.4, "y":[0,12], "setting":"clouds" }; elements[name+"_gas"].reactions["hail_cloud"]= { "elem1": null, "elem2": name + "_cloud", "chance":0.4, "y":[0,12], "setting":"clouds" };
elements[name+"_gas"].reactions["pyrocumulus"]= { "elem1": null, "elem2": name + "_cloud", "chance":0.4, "y":[0,12], "setting":"clouds" }; elements[name+"_gas"].reactions["pyrocumulus"]= { "elem1": null, "elem2": name + "_cloud", "chance":0.4, "y":[0,12], "setting":"clouds" };
elements[name+"_gas"].reactions["fire_cloud"]= { "elem1": null, "elem2": name + "_cloud", "chance":0.4, "y":[0,12], "setting":"clouds" }; elements[name+"_gas"].reactions["fire_cloud"]= { "elem1": null, "elem2": name + "_cloud", "chance":0.4, "y":[0,12], "setting":"clouds" };
} });
}
else else
{ {
elements[name+"_gas"].reactions[name+"_gas"]= { "elem1": null, "elem2": "acid_cloud", "chance":0.3, "y":[0,12], "setting":"clouds" }; elements[name+"_gas"].reactions[name+"_gas"]= { "elem1": null, "elem2": "acid_cloud", "chance":0.3, "y":[0,12], "setting":"clouds" };
@ -2278,25 +2287,25 @@ elements.disinfectant = {
}; };
elements.bauxite = { //elements.bauxite = {
color: ["#915a30","#cc7533"], // color: ["#915a30","#cc7533"],
behavior: behaviors.POWDER, // behavior: behaviors.POWDER,
category: "land", // category: "land",
density: 2420, // density: 2420,
state: "solid", // state: "solid",
tempHigh: 300 // tempHigh: 300
}; //};
//
elements.sodium_aluminate = { //elements.sodium_aluminate = {
color: ["#e6c9b3","#ebc8ad"], // color: ["#e6c9b3","#ebc8ad"],
behavior: behaviors.POWDER, // behavior: behaviors.POWDER,
category: "powders", // category: "powders",
hidden: true, // hidden: true,
density: 1500, // density: 1500,
state: "solid", // state: "solid",
tempHigh: 1650 // tempHigh: 1650
}; //};
function acidReact(acid,element,product1,product2) function acidReact(acid,element,product1,product2)
{ {
@ -2347,13 +2356,14 @@ acidNeutralize("potassium_hydroxide");
acidNeutralize("potassium_hydroxide_gas"); acidNeutralize("potassium_hydroxide_gas");
createAcid("red_mud",structuredClone(defaultBaseReactions),structuredClone(defaultBaseGasReactions),["#ab3d24","#cc5d2d","#a81b1b"],"hidden","hidden",1600,1600,0,Infinity,5200,3); //createAcid("red_mud",structuredClone(defaultBaseReactions),structuredClone(defaultBaseGasReactions),["#ab3d24","#cc5d2d","#a81b1b"],"hidden","hidden",1600,1600,0,Infinity,5200,3);
acidNeutralize("red_mud"); //acidNeutralize("red_mud");
acidNeutralize("red_mud_gas"); //acidNeutralize("red_mud_gas");
elements.red_mud.viscosity = 1000000; //elements.red_mud.viscosity = 1000000;
elements.red_mud.reactions.water = {"elem2":"dirty_water" }; //elements.red_mud.reactions.water = {"elem2":"dirty_water" };
elements.red_mud.reactions.salt_water = {"elem2":"dirty_water" }; //elements.red_mud.reactions.salt_water = {"elem2":"dirty_water" };
elements.red_mud.reactions.sugar_water = {"elem2":"dirty_water" }; //elements.red_mud.reactions.sugar_water = {"elem2":"dirty_water" };
elements.potassium_hydroxide.reactions["fertilizer"] = { elem1: "niter", elem2: "ammonia"}; elements.potassium_hydroxide.reactions["fertilizer"] = { elem1: "niter", elem2: "ammonia"};
elements.potassium_hydroxide_gas.reactions["fertilizer"] = { elem1: "niter", elem2: "ammonia"}; elements.potassium_hydroxide_gas.reactions["fertilizer"] = { elem1: "niter", elem2: "ammonia"};
@ -2373,8 +2383,8 @@ elements.potassium_salt_water.reactions["mercury"] = { elem1:["potassium_hydroxi
elements.potassium_hydroxide.ignore.push("mercury"); elements.potassium_hydroxide.ignore.push("mercury");
elements.potassium_hydroxide.ignore.push("potassium_salt_water"); elements.potassium_hydroxide.ignore.push("potassium_salt_water");
acidReact("sodium_hydroxide","bauxite","sodium_aluminate","red_mud") //acidReact("sodium_hydroxide","bauxite","sodium_aluminate","red_mud")
elements.red_mud.ignore.push("bauxite","sodium_aluminate"); //elements.red_mud.ignore.push("bauxite","sodium_aluminate");
elements.bless.reactions["FOOF"] = {elem2: "oxygen"}; elements.bless.reactions["FOOF"] = {elem2: "oxygen"};
elements.bless.reactions["solid_FOOF"] = {elem2: "oxygen"}; elements.bless.reactions["solid_FOOF"] = {elem2: "oxygen"};
@ -2407,7 +2417,6 @@ elements.bless.reactions["sulfur_dioxide_ice"] = {elem2: "oxygen"};
elements.bless.reactions["hydrogen_sulfide"] = {elem2: "hydrogen"}; elements.bless.reactions["hydrogen_sulfide"] = {elem2: "hydrogen"};
elements.bless.reactions["liquid_hydrogen_sulfide"] = {elem2: "hydrogen"}; elements.bless.reactions["liquid_hydrogen_sulfide"] = {elem2: "hydrogen"};
elements.bless.reactions["rocket_fuel"] = {elem2: null}; elements.bless.reactions["rocket_fuel"] = {elem2: null};
// do something
}); });
} else { } else {
if(!enabledMods.includes(runAfterAutogenMod)) { enabledMods.unshift(runAfterAutogenMod) }; if(!enabledMods.includes(runAfterAutogenMod)) { enabledMods.unshift(runAfterAutogenMod) };

View File

@ -1,11 +1,30 @@
function whenAvailable(names, callback) {
var interval = 10; // ms
window.setTimeout(function() {
let bool = true;
for(let i = 0; i < names.length; i++)
{
if(!window[names[i]])
{
bool = false;
}
}
if (bool) {
callback();
} else {
whenAvailable(names, callback);
}
}, interval);
}
var modName = "mods/generative_mods.js"; var modName = "mods/generative_mods.js";
var explodeAtPlusMod = "mods/explodeAtPlus.js"; var explodeAtPlusMod = "mods/explodeAtPlus.js";
var runAfterAutogenMod = "mods/runAfterAutogen and onload restructure.js"; var runAfterAutogenMod = "mods/runAfterAutogen2.js";
var libraryMod = "mods/code_library.js"; var libraryMod = "mods/code_library.js";
var feyAndMoreMod = "mods/fey_and_more.js"; var feyAndMoreMod = "mods/fey_and_more.js";
var mobsMod = "mods/mobs.js"; var mobsMod = "mods/mobs.js";
if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(explodeAtPlusMod) && enabledMods.includes(libraryMod) && enabledMods.includes(feyAndMoreMod) && enabledMods.includes(mobsMod)) { if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(explodeAtPlusMod) && enabledMods.includes(libraryMod) && enabledMods.includes(feyAndMoreMod) && enabledMods.includes(mobsMod)) {
whenAvailable(["eLists","explodeAtPlus","urlParams","runAfterAutogen","mobsLoaded"], function() {
//urlParams reads //urlParams reads
@ -1331,7 +1350,7 @@ if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(explodeAtPlu
//Bombs //Bombs
function generateBomb(bombElements,isAfterScriptLoading=false,bombNumber=1) {//it can be a single element, though generateBomb = function(bombElements,isAfterScriptLoading=false,bombNumber=1) {//it can be a single element, though
bombNumber = Math.max(0,bombNumber); bombNumber = Math.max(0,bombNumber);
//To specify an array bomb, have the array be inside another array. //To specify an array bomb, have the array be inside another array.
@ -1490,7 +1509,7 @@ if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(explodeAtPlu
//Clouds //Clouds
function generateCloud(cloudElements,cloudType=0,isAfterScriptLoading=false) {//it can be a single element, though generateCloud = function(cloudElements,cloudType=0,isAfterScriptLoading=false) {//it can be a single element, though
//To specify an array cloud, have the array be inside another array. //To specify an array cloud, have the array be inside another array.
/*For reasons related to how element colors are loaded, if this function is being run from a JS mod file, isAfterScriptLoading should be false. /*For reasons related to how element colors are loaded, if this function is being run from a JS mod file, isAfterScriptLoading should be false.
Otherwise, you'll get TypeErrors for some reason when trying to place your cloud. If this is being run after the game has loaded (e.g. in the console), Otherwise, you'll get TypeErrors for some reason when trying to place your cloud. If this is being run after the game has loaded (e.g. in the console),
@ -1698,7 +1717,7 @@ if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(explodeAtPlu
//Creepers //Creepers
function generateCreeper(creeperElements,isAfterScriptLoading=false) {//it can be a single element, though generateCreeper = function(creeperElements,isAfterScriptLoading=false) {//it can be a single element, though
//To specify an array creeper, have the array be inside another array. //To specify an array creeper, have the array be inside another array.
/*For reasons related to how element colors are loaded, if this function is being run from a JS mod file, isAfterScriptLoading should be false. /*For reasons related to how element colors are loaded, if this function is being run from a JS mod file, isAfterScriptLoading should be false.
Otherwise, you'll get TypeErrors for some reason when trying to place your creeper. If this is being run after the game has loaded (e.g. in the console), Otherwise, you'll get TypeErrors for some reason when trying to place your creeper. If this is being run after the game has loaded (e.g. in the console),
@ -1929,7 +1948,7 @@ if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(explodeAtPlu
//Fairies //Fairies
function generateFairy(fairyElements,isAfterScriptLoading=false) {//it can be a single element, though generateFairy = function(fairyElements,isAfterScriptLoading=false) {//it can be a single element, though
//To specify an array fairy, have the array be inside another array. //To specify an array fairy, have the array be inside another array.
/*For reasons related to how element colors are loaded, if this function is being run from a JS mod file, isAfterScriptLoading should be false. /*For reasons related to how element colors are loaded, if this function is being run from a JS mod file, isAfterScriptLoading should be false.
Otherwise, you'll get TypeErrors for some reason when trying to place your fairy. If this is being run after the game has loaded (e.g. in the console), Otherwise, you'll get TypeErrors for some reason when trying to place your fairy. If this is being run after the game has loaded (e.g. in the console),
@ -2118,7 +2137,7 @@ if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(explodeAtPlu
//Spouts //Spouts
function generateSpout(spoutElements,isAfterScriptLoading=false) {//it can be a single element, though generateSpout = function(spoutElements,isAfterScriptLoading=false) {//it can be a single element, though
//To specify an array spout, have the array be inside another array. //To specify an array spout, have the array be inside another array.
/*For reasons related to how element colors are loaded, if this function is being run from a JS mod file, isAfterScriptLoading should be false. /*For reasons related to how element colors are loaded, if this function is being run from a JS mod file, isAfterScriptLoading should be false.
Otherwise, you'll get TypeErrors for some reason when trying to place your spout. If this is being run after the game has loaded (e.g. in the console), Otherwise, you'll get TypeErrors for some reason when trying to place your spout. If this is being run after the game has loaded (e.g. in the console),
@ -2494,6 +2513,7 @@ if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(explodeAtPlu
elements[name].behavior = behaviors.FAIRYKILL; elements[name].behavior = behaviors.FAIRYKILL;
}; };
}; };
});
} else { } else {
if(!enabledMods.includes(runAfterAutogenMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,runAfterAutogenMod) }; if(!enabledMods.includes(runAfterAutogenMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,runAfterAutogenMod) };
if(!enabledMods.includes(explodeAtPlusMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,explodeAtPlusMod) }; if(!enabledMods.includes(explodeAtPlusMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,explodeAtPlusMod) };

View File

@ -1,9 +1,29 @@
function whenAvailable(names, callback) {
var interval = 10; // ms
window.setTimeout(function() {
let bool = true;
for(let i = 0; i < names.length; i++)
{
if(!window[names[i]])
{
bool = false;
}
}
if (bool) {
callback();
} else {
whenAvailable(names, callback);
}
}, interval);
}
var modName = "mods/metals.js"; var modName = "mods/metals.js";
var changeTempMod = "mods/changeTempReactionParameter.js"; var changeTempMod = "mods/changeTempReactionParameter.js";
var runAfterAutogenMod = "mods/runAfterAutogen and onload restructure.js"; var runAfterAutogenMod = "mods/runAfterAutogen2.js";
var libraryMod = "mods/code_library.js"; var libraryMod = "mods/code_library.js";
var onTryMoveIntoMod = "mods/onTryMoveInto.js"; var onTryMoveIntoMod = "mods/onTryMoveInto.js";
if(enabledMods.includes(changeTempMod) && enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(libraryMod) && enabledMods.includes(onTryMoveIntoMod)) { if(enabledMods.includes(changeTempMod) && enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(libraryMod) && enabledMods.includes(onTryMoveIntoMod)) {
whenAvailable(["runAfterAutogen"], function() {
elements.iron.hardness = 0.74 elements.iron.hardness = 0.74
//https://www.engineeringtoolbox.com/bhn-brinell-hardness-number-d_1365.html //https://www.engineeringtoolbox.com/bhn-brinell-hardness-number-d_1365.html
//https://en.wikipedia.org/wiki/Hardnesses_of_the_elements_(data_page) //https://en.wikipedia.org/wiki/Hardnesses_of_the_elements_(data_page)
@ -761,6 +781,7 @@ if(enabledMods.includes(changeTempMod) && enabledMods.includes(runAfterAutogenMo
conduct: 0.35, conduct: 0.35,
hardness: 0.7, //idk lol hardness: 0.7, //idk lol
}; };
});
} else { } else {
if(!enabledMods.includes(changeTempMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,changeTempMod) }; if(!enabledMods.includes(changeTempMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,changeTempMod) };
if(!enabledMods.includes(runAfterAutogenMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,runAfterAutogenMod) }; if(!enabledMods.includes(runAfterAutogenMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,runAfterAutogenMod) };

View File

@ -1,9 +1,28 @@
function whenAvailable(names, callback) {
var interval = 10; // ms
window.setTimeout(function() {
let bool = true;
for(let i = 0; i < names.length; i++)
{
if(!window[names[i]])
{
bool = false;
}
}
if (bool) {
callback();
} else {
whenAvailable(names, callback);
}
}, interval);
}
var modName = "mods/mobs.js"; var modName = "mods/mobs.js";
var explodeAtPlusMod = "mods/explodeAtPlus.js"; var explodeAtPlusMod = "mods/explodeAtPlus.js";
var runAfterAutogenMod = "mods/runAfterAutogen and onload restructure.js"; var runAfterAutogenMod = "mods/runAfterAutogen2.js";
var libraryMod = "mods/code_library.js"; var libraryMod = "mods/code_library.js";
var mobsLoaded = false;
if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(explodeAtPlusMod) && enabledMods.includes(libraryMod)) { if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(explodeAtPlusMod) && enabledMods.includes(libraryMod)) {
whenAvailable(["runAfterAutogen","explodeAtPlus"], function() {
//Prerequisite Functions and Variables //Prerequisite Functions and Variables
minimumCreeperTries = 3; minimumCreeperTries = 3;
@ -5117,6 +5136,8 @@ if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(explodeAtPlu
/* ------------------------- /* -------------------------
- End skeleton elements - - End skeleton elements -
------------------------- */ ------------------------- */
mobsLoaded = true;
});
} else { } else {
if(!enabledMods.includes(runAfterAutogenMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,runAfterAutogenMod) }; if(!enabledMods.includes(runAfterAutogenMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,runAfterAutogenMod) };
if(!enabledMods.includes(explodeAtPlusMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,explodeAtPlusMod) }; if(!enabledMods.includes(explodeAtPlusMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,explodeAtPlusMod) };

View File

@ -1,8 +1,27 @@
function whenAvailable(names, callback) {
var interval = 10; // ms
window.setTimeout(function() {
let bool = true;
for(let i = 0; i < names.length; i++)
{
if(!window[names[i]])
{
bool = false;
}
}
if (bool) {
callback();
} else {
whenAvailable(names, callback);
}
}, interval);
}
var modName = "mods/neutronium_compressor.js"; var modName = "mods/neutronium_compressor.js";
var runAfterAutogenMod = "mods/runAfterAutogen and onload restructure.js"; var runAfterAutogenMod = "mods/runAfterAutogen2.js";
var libraryMod = "mods/code_library.js"; var libraryMod = "mods/code_library.js";
if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(libraryMod)) { if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(libraryMod)) {
whenAvailable(["urlParams","runAfterAutogen"], function() {
var singularityColorTemplate = ["#202020", "#505050", "#b0b0b0", "#c7c7c7"]; var singularityColorTemplate = ["#202020", "#505050", "#b0b0b0", "#c7c7c7"];
singularityNumber = 10000; singularityNumber = 10000;
@ -388,6 +407,7 @@ if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(libraryMod))
//Post-generation tasks //Post-generation tasks
});
} else { } else {
if(!enabledMods.includes(runAfterAutogenMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,runAfterAutogenMod) }; if(!enabledMods.includes(runAfterAutogenMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,runAfterAutogenMod) };
if(!enabledMods.includes(libraryMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,libraryMod) }; if(!enabledMods.includes(libraryMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,libraryMod) };

View File

@ -1,8 +1,28 @@
function whenAvailable(names, callback) {
var interval = 10; // ms
window.setTimeout(function() {
let bool = true;
for(let i = 0; i < names.length; i++)
{
if(!window[names[i]])
{
bool = false;
}
}
if (bool) {
callback();
} else {
whenAvailable(names, callback);
}
}, interval);
}
var modName = "mods/rays.js"; var modName = "mods/rays.js";
var runAfterAutogenMod = "mods/runAfterAutogen and onload restructure.js"; var runAfterAutogenMod = "mods/runAfterAutogen2.js";
var libraryMod = "mods/code_library.js"; var libraryMod = "mods/code_library.js";
if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(libraryMod)) { if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(libraryMod)) {
whenAvailable(["runAfterAutogen","libraryLoaded"], function() {
runAfterAutogen(function() { runAfterAutogen(function() {
snowAndIceCache = Object.keys(elements).filter(function(name) { snowAndIceCache = Object.keys(elements).filter(function(name) {
return name.endsWith("snow") || name.endsWith("ice") || name == "rime" return name.endsWith("snow") || name.endsWith("ice") || name == "rime"
@ -435,7 +455,7 @@ if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(libraryMod))
} }
} }
}; };
});
} else { } else {
if(!enabledMods.includes(libraryMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,libraryMod) }; if(!enabledMods.includes(libraryMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,libraryMod) };
if(!enabledMods.includes(runAfterAutogenMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,runAfterAutogenMod) }; if(!enabledMods.includes(runAfterAutogenMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,runAfterAutogenMod) };

52
mods/runAfterAutogen2.js Normal file
View File

@ -0,0 +1,52 @@
//runs after the elements in "names" are defined
function runAfterAutogen(callback) {
var interval = 10; // ms
window.setTimeout(function() {
if (window.autoElements) {
callback();
} else {
runAfterAutogen(callback);
}
}, interval);
}
function createButtonsAndCountElements() {
document.getElementById("categoryControls").innerHTML = "";
document.getElementById("elementControls").innerHTML = "";
document.getElementById("extraInfo").innerHTML = "";
elementCount = 0;
hiddenCount = 0;
categoryList = [];
for (var element in elements) {
elementCount++;
if (settings.cheerful && elements[element].nocheer) {
elements[element].hidden = true;
hiddenCount++;
continue;
}
if (element === "unknown") {continue;}
var category = elements[element].category;
if (category==null) {category="other"}
if (categoryList.indexOf(category) === -1) {
categoryList.push(category);
}
if (elements[element].hidden && (!settings["unhide"] || ( settings["unhide"]===2 && !settings.unlocked[element] ))) { hiddenCount++; continue; }
var categoryDiv = document.getElementById("category-"+category);
if (categoryDiv == null) {
createCategoryDiv(category);
categoryDiv = document.getElementById("category-"+category);
}
createElementButton(element);
}
if (document.getElementById("categoryButton-states")) {
// move it to the end of its parent
document.getElementById("categoryButton-states").parentNode.appendChild(document.getElementById("categoryButton-states"));
}
// Set the first button in categoryControls div to be the current category
document.getElementById("categoryControls").children[0].click()
document.getElementById("extraInfo").insertAdjacentHTML("beforeend", "<small><p>v" + currentversion + " • " + elementCount + " elements, including " + hiddenCount + " hidden ones.</p><p>©2021-" + new Date().getFullYear() + ". All Rights Reserved. <a style='color:#00ffff' href='https://r74n.com'>R74n</a></p></small>");
selectElement(currentElement);
};
runAfterAutogen(createButtonsAndCountElements);

View File

@ -15,7 +15,7 @@ var libHookTickMod = "mods/libhooktick.js";
var propertyLibrary = "mods/special_property_library.js"; var propertyLibrary = "mods/special_property_library.js";
//someone retroactively turned off ??= assignment on undeclared variables /hj //someone retroactively turned off ??= assignment on undeclared variables /hj
if(!urlParams) { urlParams = new URLSearchParams(window.location.search) }; if(!window["urlParams"] || !urlParams) { urlParams = new URLSearchParams(window.location.search) };
modRequirementsPartOne = (enabledMods.includes(libraryMod) && enabledMods.includes(colorOffsetMod)); modRequirementsPartOne = (enabledMods.includes(libraryMod) && enabledMods.includes(colorOffsetMod));
if(urlParams.get("radiationSystemEnabled") === null) { if(urlParams.get("radiationSystemEnabled") === null) {