2 torch.directions = ["floor", "left", "right", "ceiling"];
3 torch.check = function(direction, map, x, y){
6 return ! map.getNode(x, y + 1) || map.getNode(x, y + 1).stable;
8 return ! map.getNode(x - 1, y) || map.getNode(x - 1, y).stable;
10 return ! map.getNode(x + 1, y) || map.getNode(x + 1, y).stable;
12 return ! map.getNode(x, y - 1) || map.getNode(x, y - 1).stable;
15 dragonblocks.registerItem({
18 texture: "torch_torch_floor.png",
19 onuse: (map, x, y) => {
20 for(let direction of torch.directions)
21 if(dragonblocks.player.place(map, x, y, dragonblocks.nodes["torch:torch_" + direction]))
25 for(let direction of torch.directions){
26 dragonblocks.registerNode({
27 name: "torch:torch_" + direction,
33 texture: "torch_torch_" + direction + ".png",
36 onactivate: (map, x, y) => {
37 if(! torch.check(direction, map, x, y))
38 map.setNode(x, y, "air");
40 onplace: (map, x, y) => {
41 if(! torch.check(direction, map, x, y))
46 dragonblocks.registerRecipe({
47 result: "torch:torch 4",