1.0.1 mod compatibility

This commit is contained in:
slweeb 2022-01-20 15:02:20 -05:00
parent bbee23bb18
commit d3236256fa
3 changed files with 21 additions and 1 deletions

View File

@ -3,6 +3,10 @@
+ Explosives Update
+ Machines Update
[Version 1.0.1]
~ Slowed down Udder
+ Technical: runAfterLoad() function, pass a function to run after all mods load. See example_mod.js
[Version 1.0 - Full Steam Ahead!]
+ Radiation
+ Uranium

View File

@ -339,6 +339,11 @@
console.log(e);
}
}
runAfterLoadList = [];
// runAfterLoad() takes a function and adds it to the runAfterLoadList.
function runAfterLoad(func) {
runAfterLoadList.push(func);
}
</script>
<script>
@ -1514,7 +1519,7 @@
behavior: [
"XX|XX|XX",
"XX|XX|XX",
"XX|CR:milk%5|XX",
"XX|CR:milk%2.5|XX",
],
category:"special",
},
@ -5303,6 +5308,11 @@ for (var k = 0; k < b0.split(" AND ").length; k++) {
function focusGame() { document.getElementById("game").focus(); if(showingMenu) { closeMenu(); } }
//on window load
window.onload = function() {
// Loop through runAfterLoadList and run each function
for (var i = 0; i < runAfterLoadList.length; i++) {
runAfterLoadList[i]();
}
// Loop through behaviors and each behavior, if it is a string, split the items and replace the value with the array
for (var behavior in behaviors) {
if (typeof behaviors[behavior][0] === "string") {

View File

@ -40,6 +40,12 @@ if (!elements.water.reactions) { // Include this block once
elements.water.reactions.mayo = { "elem1":null, "elem2":"mayo_water" }
elements.water.reactions.soap = { "elem1":null, "elem2":"soapy_water" }
// Run after all mods are loaded, for cross-mod compatibility
runAfterLoad(function() {
// Your code here
console.log("Hello World!");
});
// Creating eLists:
eLists.CONDIMENT = ["ketchup","melted_cheese","mayo"];
// Adding elements to eLists: