mirror of
https://github.com/danbulant/flying-squid
synced 2026-07-06 19:50:40 +00:00
properly implement /kill using selectors
This commit is contained in:
parent
31a8d18aa0
commit
a770046407
2 changed files with 13 additions and 6 deletions
|
|
@ -89,7 +89,7 @@ module.exports.player=function(player, serv) {
|
||||||
else if (arr == null) return 'Could not find player';
|
else if (arr == null) return 'Could not find player';
|
||||||
else player.chat(JSON.stringify(arr.map(a => a.id)));
|
else player.chat(JSON.stringify(arr.map(a => a.id)));
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
|
|
||||||
player.handleCommand = async (str) => {
|
player.handleCommand = async (str) => {
|
||||||
|
|
|
||||||
|
|
@ -36,12 +36,19 @@ module.exports.player=function(player,serv)
|
||||||
});
|
});
|
||||||
|
|
||||||
player.commands.add({
|
player.commands.add({
|
||||||
base: 'killall',
|
base: 'kill',
|
||||||
info: 'Kill everything',
|
info: 'Kill entities',
|
||||||
usage: '/killall',
|
usage: '/kill <selector>',
|
||||||
op: true,
|
op: true,
|
||||||
action() {
|
parse(str) {
|
||||||
Object.keys(serv.entities).forEach(key => serv.entities[key].takeDamage({damage:20}));
|
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}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue