Create periodic_and_more.js

This is a WIP mod for Sandboxels.
This commit is contained in:
Boxeled 2024-07-29 16:15:10 -05:00 committed by GitHub
parent 4b05c9d394
commit af2eb5c494
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 81 additions and 0 deletions

81
mods/periodic_and_more.js Normal file
View File

@ -0,0 +1,81 @@
// This is how to add a new mod to the game.
// Create a new Javascript file like this one.
// Add the file to the mods folder on GitHub, or host it somewhere else.
// https://github.com/R74nCom/sandboxels/tree/main/mods
// To add it in the Mod Loader:
// If it is in the mods folder, you can just use the name of the file.
// If it is hosted somewhere else, you can use the full URL, including the HTTPS://.
// Adding elements:
elements.mayo = {
color: "#ffffff",
behavior: behaviors.LIQUID,
category: "liquids",
viscosity: 100000,
state: "liquid",
density: 720,
};
// Changing existing elements:
elements.water.color = "#ff0000";
elements.water.behavior = behaviors.WALL;
// Removing elements:
// Be aware, things may break
delete elements.ketchup;
// Adding behavior presets:
behaviors.SELFDELETE = [
"XX|XX|XX",
"XX|DL|XX",
"XX|XX|XX",
];
// Raw JavaScript behaviors:
behaviors.mud.tick = function(pixel) {
if (tryMove(pixel, pixel.x, pixel.y+1)) {
console.log("Moved!");
}
else {
console.log("Couldn't move!")
}
};
// Create a new tool:
elements.sand_exploder = {
color: "#ff0000",
tool: function(pixel) {
if (pixel.element == "sand") {
pixel.element = "explosion"
}
},
category: "tools",
};
// Add reactions to existing elements
if (!elements.water.reactions) { // Include this block once
elements.water.reactions = {} // This creates the property if it doesn't exist
}
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!");
});
// Run if another mod is active
if (enabledMods.includes("mods/test.js")) {
runAfterLoad(function() {
// Your code here
console.log("Hello World!");
});
}
// Creating eLists:
eLists.PERIODIC = ["beryllium", "scandium", "vanadium", "manganese", "cobalt"];
// Adding elements to eLists:
eLists.CONDIMENT.push("honey");