1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-06-30 11:47:45 +00:00

Log in-game and in the server when encountering an unknown command

Instead of printing nothing and you're just left scratching your head.
This commit is contained in:
Joshua Goins 2025-06-21 12:23:25 -04:00
parent f07d16b949
commit bb2cc9e0ec
2 changed files with 16 additions and 0 deletions

View file

@ -13,6 +13,10 @@ function onCommandRequiredRankMissingError(additional_information, player)
player:send_message(string.format("%s\nAdditional information: %s", error_msg, additional_information))
end
function onUnknownCommandError(command_name, player)
player:send_message(string.format("Unknown command %s", command_name))
end
function split(input, separator)
if separator == nil then
separator = '%s'

View file

@ -564,6 +564,18 @@ async fn client_loop(
}
})
.unwrap();
} else {
tracing::info!("Unknown command {command_name}");
lua.scope(|scope| {
let connection_data = scope
.create_userdata_ref_mut(&mut lua_player)
.unwrap();
let func: Function =
lua.globals().get("onUnknownCommandError").unwrap();
func.call::<()>((command_name, connection_data)).unwrap();
Ok(())
}).unwrap();
}
}