forked from R74nCom/sandboxels
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_mod2.js
More file actions
89 lines (78 loc) · 2.4 KB
/
example_mod2.js
File metadata and controls
89 lines (78 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// To create a mod:
// 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 learn about modding, check the wiki: https://sandboxels.wiki.gg/wiki/Modding
// Or join our Discord: https://r74n.com/discord/
// 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 hosted somewhere else, you can use the full URL, including the HTTPS://.
// Adding elements:
elements.mustard = {
color: "#ffff00",
behavior: behaviors.LIQUID,
category: "liquids",
state: "liquid",
density: 1100,
viscosity: 60000,
}
// Changing existing elements:
elements.water.color = "#ff0000";
elements.water.behavior = behaviors.WALL;
// Removing elements:
// Be aware, things may break
delete elements.ketchup;
// Custom behaviors:
elements.blue_sand = {
color: "#0000ff",
behavior: [
"XX|XX|XX",
"XX|XX|XX",
"M2|M1|M2"
],
category: "land",
state: "solid"
}
// 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",
};
// Reactions:
elements.sugar_stick = {
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
}
// 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" };
// Custom element renderers:
elements.ball.renderer = function(pixel,ctx) {
// Draw three horizontal squares
drawSquare(ctx,"#00ff00",pixel.x-1,pixel.y);
drawSquare(ctx,"#00ff00",pixel.x,pixel.y);
drawSquare(ctx,"#00ff00",pixel.x+1,pixel.y);
};
// See 1.10example.js for more rendering examples.