mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
make amount optional
This commit is contained in:
parent
c859371ddb
commit
2cc2a36be2
@ -88,7 +88,7 @@ lazy_static! {
|
||||
ChatCommand::new(
|
||||
"spawn",
|
||||
"{} {} {d}",
|
||||
"/spawn <alignment> <entity> <amount> : Spawn a test entity",
|
||||
"/spawn <alignment> <entity> [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
|
||||
|
Loading…
Reference in New Issue
Block a user