1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-06-21 07:27:45 +00:00

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).
This commit is contained in:
The Dax 2025-06-19 14:16:30 -04:00 committed by Joshua Goins
parent 961cb92ab1
commit ae96de1ee6

View file

@ -538,10 +538,15 @@ async fn client_loop(
let func: Function = let func: Function =
lua.globals().get("onCommand").unwrap(); lua.globals().get("onCommand").unwrap();
tracing::info!("{}", &chat_message.message[command_name.len() + 2..]); let mut func_args = "";
if parts.len() > 1 {
func.call::<()>((&chat_message.message[command_name.len() + 2..], connection_data)) func_args = &chat_message.message[command_name.len() + 2..];
.unwrap(); 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(()) Ok(())
}) })