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:
parent
961cb92ab1
commit
ae96de1ee6
1 changed files with 9 additions and 4 deletions
|
@ -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(())
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue