From ae96de1ee606141d8301beb8f75dacd98a1075c7 Mon Sep 17 00:00:00 2001 From: The Dax Date: Thu, 19 Jun 2025 14:16:30 -0400 Subject: [PATCH] Stop the world server from becoming upset when a Lua command is invoked with no arguments. Allows commands that have a default set of arg(s) to use those when none are specified, as well as allowing commands to act as toggles (such as a wireframe toggle, or disabling any set festivals). --- src/bin/kawari-world.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/bin/kawari-world.rs b/src/bin/kawari-world.rs index fa4c0de..519a873 100644 --- a/src/bin/kawari-world.rs +++ b/src/bin/kawari-world.rs @@ -538,10 +538,15 @@ async fn client_loop( let func: Function = lua.globals().get("onCommand").unwrap(); - tracing::info!("{}", &chat_message.message[command_name.len() + 2..]); - - func.call::<()>((&chat_message.message[command_name.len() + 2..], connection_data)) - .unwrap(); + let mut func_args = ""; + if parts.len() > 1 { + func_args = &chat_message.message[command_name.len() + 2..]; + tracing::info!("Args passed to Lua command {}: {}", command_name, func_args); + } else { + tracing::info!("No additional args passed to Lua command {}.", command_name); + } + func.call::<()>((func_args, connection_data)). + unwrap(); Ok(()) })