diff --git a/server/src/cmd.rs b/server/src/cmd.rs index dc5efc85ec..c3a13f7db6 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -88,7 +88,7 @@ lazy_static! { ChatCommand::new( "spawn", "{} {} {d}", - "/spawn : Spawn a test entity", + "/spawn [amount] : Spawn a test entity", handle_spawn ), ChatCommand::new( @@ -211,9 +211,15 @@ fn handle_tp(server: &mut Server, entity: EcsEntity, args: String, action: &Chat } fn handle_spawn(server: &mut Server, entity: EcsEntity, args: String, action: &ChatCommand) { - let (opt_align, opt_id, opt_amount) = scan_fmt!(&args, action.arg_fmt, String, NpcKind, u32); - // This should probably be just an enum and be handled with scan_fmt! + let (opt_align, opt_id, opt_amount) = scan_fmt!(&args, action.arg_fmt, String, NpcKind, String); + // This should be just an enum and be handled with scan_fmt! let opt_agent = alignment_to_agent(&opt_align.unwrap_or(String::new()), entity); + + // Make sure the amount is either not provided or a valid value + let opt_amount = if let Some(amount) = opt_amount { + amount.parse().ok() + } else { Some(1) }; + match (opt_agent, opt_id, opt_amount) { (Some(agent), Some(id), Some(amount)) => { match server