properly implement /kill using selectors

This commit is contained in:
Romain Beaumont 2015-12-09 01:12:04 +01:00
parent 31a8d18aa0
commit a770046407
2 changed files with 13 additions and 6 deletions

View file

@ -89,7 +89,7 @@ module.exports.player=function(player, serv) {
else if (arr == null) return 'Could not find player';
else player.chat(JSON.stringify(arr.map(a => a.id)));
}
})
});
player.handleCommand = async (str) => {

View file

@ -36,12 +36,19 @@ module.exports.player=function(player,serv)
});
player.commands.add({
base: 'killall',
info: 'Kill everything',
usage: '/killall',
base: 'kill',
info: 'Kill entities',
usage: '/kill <selector>',
op: true,
action() {
Object.keys(serv.entities).forEach(key => serv.entities[key].takeDamage({damage:20}));
parse(str) {
return str || false;
},
action(sel) {
var arr = serv.selectorString(sel, player.position.scaled(1/32), player.world);
if (arr instanceof Error) return arr.toString();
if (arr == null) return 'Could not find player';
arr.map(entity => entity.takeDamage({damage:20}));
}
});