Skip to content

Commit 9550ef1

Browse files
committed
count option for /spawn
1 parent 3136d5e commit 9550ef1

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed

build/scripts/staffCommands.js

Lines changed: 15 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/staffCommands.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -645,20 +645,25 @@ export const commands = commandList({
645645
},
646646

647647
spawn: {
648-
args: ["type:unittype", "x:number?", "y:number?", "team:team?", "effects:string?"],
648+
args: ["type:unittype", "x:number?", "y:number?", "count:number?", "team:team?", "effects:string?", "stack:boolean?"],
649649
description: "Spawns a unit of specified type at your position. [scarlet]Usage will be logged.[]",
650650
perm: Perm.admin,
651651
data: [],
652652
handler({sender, args, data, outputSuccess, f}){
653653
const x = args.x ? (args.x * 8) : sender.player!.x;
654654
const y = args.y ? (args.y * 8) : sender.player!.y;
655655
const team = args.team ?? sender.team();
656-
const unit = args.type.create(team);
657-
unit.set(x, y);
658-
if(args.effects) applyEffectMode(args.effects, unit, 1e12);
659-
unit.add();
660-
data.push(unit);
661-
if(!Gamemode.sandbox()) logAction(`spawned unit ${args.type.name} at ${Math.round(x / 8)}, ${Math.round(y / 8)}`, sender);
656+
const count = Math.min(args.count ?? 1, 1000);
657+
for(let i = 0; i < count; i ++){
658+
const unit = args.type.create(team);
659+
const xOffset = args.stack ? 0 : 0.01 * i;
660+
const yOffset = args.stack ? 0 : 0.5 * (i % 10);
661+
unit.set(x + xOffset, y + yOffset);
662+
if(args.effects) applyEffectMode(args.effects, unit, 1e12);
663+
unit.add();
664+
data.push(unit);
665+
}
666+
if(!Gamemode.sandbox() && args.effects !== 'paper') logAction(`spawned unit ${args.type.name}${count == 1 ? '' : ` x${count}`} at ${Math.round(x / 8)}, ${Math.round(y / 8)}` + (args.effects ? `with ${args.effects} effects` : ''), sender);
662667
outputSuccess(f`Spawned unit ${args.type} at (${Math.round(x / 8)}, ${Math.round(y / 8)})`);
663668
}
664669
},

0 commit comments

Comments
 (0)