2022-01-16 20:17:12 -05:00
|
|
|
// 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.
|
2023-09-22 12:31:57 -04:00
|
|
|
// https://github.com/R74nCom/sandboxels/tree/main/mods
|
2022-01-16 20:17:12 -05:00
|
|
|
|
|
|
|
|
// 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",
|
|
|
|
|
];
|
|
|
|
|
|
2022-02-11 15:29:59 -05:00
|
|
|
// 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",
|
|
|
|
|
};
|
|
|
|
|
|
2022-01-19 20:05:54 -05:00
|
|
|
// 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" }
|
|
|
|
|
|
2022-01-20 15:02:20 -05:00
|
|
|
// Run after all mods are loaded, for cross-mod compatibility
|
|
|
|
|
runAfterLoad(function() {
|
|
|
|
|
// Your code here
|
|
|
|
|
console.log("Hello World!");
|
|
|
|
|
});
|
|
|
|
|
|
2022-02-04 20:01:14 -05:00
|
|
|
// Run if another mod is active
|
|
|
|
|
if (enabledMods.includes("test.js")) {
|
|
|
|
|
runAfterLoad(function() {
|
|
|
|
|
// Your code here
|
|
|
|
|
console.log("Hello World!");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-16 20:17:12 -05:00
|
|
|
// Creating eLists:
|
|
|
|
|
eLists.CONDIMENT = ["ketchup","melted_cheese","mayo"];
|
|
|
|
|
// Adding elements to eLists:
|
|
|
|
|
eLists.CONDIMENT.push("honey");
|
|
|
|
|
|