X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=game%2Ftorch%2Finit.js;h=956996fcb97892a94cfa9a66cd2c26367f30a53d;hb=2080786285404ee09c3f1b26fcd1b41abfb113db;hp=418d7be0c20a76483a374d509d11de7fbc6d9dda;hpb=ee966f4331418f6ae44a2604de2b10c1d188417d;p=dragonblocks.git diff --git a/game/torch/init.js b/game/torch/init.js index 418d7be..956996f 100644 --- a/game/torch/init.js +++ b/game/torch/init.js @@ -1,24 +1,24 @@ torch = {}; torch.directions = ["floor", "left", "right", "ceiling"]; -torch.check = function(direction, x, y){ +torch.check = function(direction, map, x, y){ switch(direction){ case "floor": - return ! dragonblocks.getNode(x, y + 1) || dragonblocks.getNode(x, y + 1).stable; + return ! map.getNode(x, y + 1) || map.getNode(x, y + 1).stable; case "left": - return ! dragonblocks.getNode(x - 1, y) || dragonblocks.getNode(x - 1, y).stable; + return ! map.getNode(x - 1, y) || map.getNode(x - 1, y).stable; case "right": - return ! dragonblocks.getNode(x + 1, y) || dragonblocks.getNode(x + 1, y).stable; + return ! map.getNode(x + 1, y) || map.getNode(x + 1, y).stable; case "ceiling": - return ! dragonblocks.getNode(x, y - 1) || dragonblocks.getNode(x, y - 1).stable; + return ! map.getNode(x, y - 1) || map.getNode(x, y - 1).stable; } } dragonblocks.registerItem({ name: "torch:torch", desc: "Torch", texture: "torch_torch_floor.png", - onuse: (x, y) => { + onuse: (map, x, y) => { for(let direction of torch.directions) - if(dragonblocks.player.place(x, y, dragonblocks.nodes["torch:torch_" + direction])) + if(dragonblocks.player.place(map, x, y, dragonblocks.nodes["torch:torch_" + direction])) return true; } }); @@ -33,12 +33,12 @@ for(let direction of torch.directions){ texture: "torch_torch_" + direction + ".png", groups:["snappy"], hidden: true, - onactivate: (x, y) => { - if(! torch.check(direction, x, y)) - dragonblocks.setNode(x, y, "air"); + onactivate: (map, x, y) => { + if(! torch.check(direction, map, x, y)) + map.setNode(x, y, "air"); }, - onplace: (x, y) => { - if(! torch.check(direction, x, y)) + onplace: (map, x, y) => { + if(! torch.check(direction, map, x, y)) return false; } });