mirror of
https://github.com/redstrate/Kawari.git
synced 2025-07-09 15:37:45 +00:00
Move the login message from Lua scripts into the config file. (#100)
-Provide a new API function: getLoginMessage which will fetch it from the config file.
This commit is contained in:
parent
9532abcaa6
commit
ca90d8b787
3 changed files with 16 additions and 1 deletions
|
@ -9,7 +9,7 @@ dofile(BASE_DIR.."Global.lua")
|
|||
-- Lua error handlers, and other server events like player login
|
||||
function onBeginLogin(player)
|
||||
-- send a welcome message
|
||||
player:send_message("Welcome to Kawari!")
|
||||
player:send_message(getLoginMessage())
|
||||
end
|
||||
|
||||
function onCommandRequiredRankInsufficientError(player)
|
||||
|
|
|
@ -216,6 +216,9 @@ pub struct WorldConfig {
|
|||
/// Enable packet compression for packets from the server. It's recommended to keep this on.
|
||||
#[serde(default = "WorldConfig::default_packet_compression")]
|
||||
pub enable_packet_compression: bool,
|
||||
/// Default message received when logging into the world.
|
||||
#[serde(default = "WorldConfig::default_login_message")]
|
||||
pub login_message: String,
|
||||
}
|
||||
|
||||
impl Default for WorldConfig {
|
||||
|
@ -230,6 +233,7 @@ impl Default for WorldConfig {
|
|||
rcon_password: Self::default_rcon_password(),
|
||||
enable_packet_obsfucation: Self::default_packet_obsfucation(),
|
||||
enable_packet_compression: Self::default_packet_compression(),
|
||||
login_message: Self::default_login_message(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -270,6 +274,10 @@ impl WorldConfig {
|
|||
fn default_packet_compression() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn default_login_message() -> String {
|
||||
"Welcome to Kawari!".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
impl WorldConfig {
|
||||
|
|
|
@ -716,6 +716,11 @@ pub fn load_init_script(lua: &mut Lua) -> mlua::Result<()> {
|
|||
Ok(())
|
||||
})?;
|
||||
|
||||
let get_login_message_func = lua.create_function(|_, _: ()| {
|
||||
let config = get_config();
|
||||
Ok(config.world.login_message)
|
||||
})?;
|
||||
|
||||
lua.set_app_data(ExtraLuaState::default());
|
||||
lua.globals().set("registerAction", register_action_func)?;
|
||||
lua.globals().set("registerEvent", register_event_func)?;
|
||||
|
@ -723,6 +728,8 @@ pub fn load_init_script(lua: &mut Lua) -> mlua::Result<()> {
|
|||
.set("registerCommand", register_command_func)?;
|
||||
lua.globals()
|
||||
.set("registerGMCommand", register_gm_command_func)?;
|
||||
lua.globals()
|
||||
.set("getLoginMessage", get_login_message_func)?;
|
||||
|
||||
let effectsbuilder_constructor = lua.create_function(|_, ()| Ok(EffectsBuilder::default()))?;
|
||||
lua.globals()
|
||||
|
|
Loading…
Add table
Reference in a new issue