New example mod
This commit is contained in:
parent
4e9391d2c1
commit
ca6484d691
|
|
@ -1,25 +1,24 @@
|
||||||
// This is how to add a new mod to the game.
|
// To create a mod:
|
||||||
|
|
||||||
// Create a new Javascript file like this one.
|
// Create a new Javascript file like this one.
|
||||||
// Add the file to the mods folder on GitHub, or host it somewhere else.
|
// Add the file to the mods folder on GitHub, or host it somewhere else.
|
||||||
// https://github.com/R74nCom/sandboxels/tree/main/mods
|
// https://github.com/R74nCom/sandboxels/tree/main/mods
|
||||||
|
|
||||||
// For more help with modding, check the wiki: https://sandboxels.wiki.gg/wiki/Modding_tutorial
|
// To learn about modding, check the wiki: https://sandboxels.wiki.gg/wiki/Modding
|
||||||
// Or join our Discord: https://r74n.com/discord/
|
// Or join our Discord: https://r74n.com/discord/
|
||||||
|
|
||||||
// To add it in the Mod Loader:
|
// To add it in the Mod Manager:
|
||||||
// If it is in the mods folder, you can just use the name of the file. (example_mod.js)
|
// If it is in the mods folder, you can just use the name of the file. (example_mod.js)
|
||||||
// If it is hosted somewhere else, you can use the full URL, including the HTTPS://.
|
// If it is hosted somewhere else, you can use the full URL, including the HTTPS://.
|
||||||
|
|
||||||
// Adding elements:
|
// Adding elements:
|
||||||
elements.mayo = {
|
elements.mustard = {
|
||||||
color: "#ffffff",
|
color: "#ffff00",
|
||||||
behavior: behaviors.LIQUID,
|
behavior: behaviors.LIQUID,
|
||||||
category: "liquids",
|
category: "liquids",
|
||||||
viscosity: 100000,
|
|
||||||
state: "liquid",
|
state: "liquid",
|
||||||
density: 720
|
density: 1100,
|
||||||
};
|
viscosity: 60000,
|
||||||
|
}
|
||||||
|
|
||||||
// Changing existing elements:
|
// Changing existing elements:
|
||||||
elements.water.color = "#ff0000";
|
elements.water.color = "#ff0000";
|
||||||
|
|
@ -29,15 +28,20 @@ elements.water.behavior = behaviors.WALL;
|
||||||
// Be aware, things may break
|
// Be aware, things may break
|
||||||
delete elements.ketchup;
|
delete elements.ketchup;
|
||||||
|
|
||||||
// Adding behavior presets:
|
// Custom behaviors:
|
||||||
behaviors.SELFDELETE = [
|
elements.blue_sand = {
|
||||||
"XX|XX|XX",
|
color: "#0000ff",
|
||||||
"XX|DL|XX",
|
behavior: [
|
||||||
"XX|XX|XX"
|
"XX|XX|XX",
|
||||||
];
|
"XX|XX|XX",
|
||||||
|
"M2|M1|M2"
|
||||||
|
],
|
||||||
|
category: "land",
|
||||||
|
state: "solid"
|
||||||
|
}
|
||||||
|
|
||||||
// Raw JavaScript behaviors:
|
// Raw JavaScript behaviors:
|
||||||
behaviors.mud.tick = function(pixel) {
|
elements.mud.tick = function(pixel) {
|
||||||
if (tryMove(pixel, pixel.x, pixel.y+1)) {
|
if (tryMove(pixel, pixel.x, pixel.y+1)) {
|
||||||
console.log("Moved!");
|
console.log("Moved!");
|
||||||
}
|
}
|
||||||
|
|
@ -57,28 +61,29 @@ elements.sand_exploder = {
|
||||||
category: "tools",
|
category: "tools",
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add reactions to existing elements
|
// Reactions:
|
||||||
if (!elements.water.reactions) { // Include this block once
|
elements.sugar_stick = {
|
||||||
elements.water.reactions = {} // This creates the property if it doesn't exist
|
color: "#ffffff",
|
||||||
|
behavior: behaviors.STURDYPOWDER,
|
||||||
|
reactions: {
|
||||||
|
"water": { elem1:null, elem2:"sugar_water", chance:0.1 },
|
||||||
|
"salt_water": { elem1:null, elem2:"sugar_water", chance:0.1 }
|
||||||
|
},
|
||||||
|
state: "solid",
|
||||||
|
density: 1580
|
||||||
}
|
}
|
||||||
elements.water.reactions.mayo = { "elem1":null, "elem2":"mayo_water" };
|
|
||||||
|
// Add reactions to existing elements:
|
||||||
|
// Include this block once to ensure the property exists
|
||||||
|
if (!elements.water.reactions) elements.water.reactions = {};
|
||||||
|
elements.water.reactions.mustard = { "elem1":null, "elem2":"mustard_water" };
|
||||||
elements.water.reactions.soap = { "elem1":null, "elem2":"soapy_water" };
|
elements.water.reactions.soap = { "elem1":null, "elem2":"soapy_water" };
|
||||||
|
|
||||||
// Run after all mods are loaded, for cross-mod compatibility
|
// Custom element renderers:
|
||||||
runAfterLoad(function() {
|
elements.ball.renderer = function(pixel,ctx) {
|
||||||
// Your code here
|
// Draw three horizontal squares
|
||||||
console.log("Hello World!");
|
drawSquare(ctx,"#00ff00",pixel.x-1,pixel.y);
|
||||||
});
|
drawSquare(ctx,"#00ff00",pixel.x,pixel.y);
|
||||||
|
drawSquare(ctx,"#00ff00",pixel.x+1,pixel.y);
|
||||||
// Run if another mod is active
|
};
|
||||||
dependOn("mods/test.js", function(){
|
// See 1.10example.js for more rendering examples.
|
||||||
console.log("Hello World!");
|
|
||||||
})
|
|
||||||
// More dependency info: See dependency_test.js
|
|
||||||
|
|
||||||
// Creating eLists:
|
|
||||||
eLists.CONDIMENT = ["ketchup","melted_cheese","mayo"];
|
|
||||||
// Adding elements to eLists:
|
|
||||||
eLists.CONDIMENT.push("honey");
|
|
||||||
|
|
||||||
// Rendering: See 1.10example.js
|
|
||||||
|
|
@ -0,0 +1,84 @@
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// For more help with modding, check the wiki: https://sandboxels.wiki.gg/wiki/Modding_tutorial
|
||||||
|
// Or join our Discord: https://r74n.com/discord/
|
||||||
|
|
||||||
|
// To add it in the Mod Loader:
|
||||||
|
// If it is in the mods folder, you can just use the name of the file. (example_mod.js)
|
||||||
|
// 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:
|
||||||
|
elements.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
|
||||||
|
dependOn("mods/test.js", function(){
|
||||||
|
console.log("Hello World!");
|
||||||
|
})
|
||||||
|
// More dependency info: See dependency_test.js
|
||||||
|
|
||||||
|
// Creating eLists:
|
||||||
|
eLists.CONDIMENT = ["ketchup","melted_cheese","mayo"];
|
||||||
|
// Adding elements to eLists:
|
||||||
|
eLists.CONDIMENT.push("honey");
|
||||||
|
|
||||||
|
// Rendering: See 1.10example.js
|
||||||
Loading…
Reference in New Issue