1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-07-17 10:47:44 +00:00

Begin laying infrastructure for status effect scripting

This commit is contained in:
Joshua Goins 2025-07-14 19:19:21 -04:00
parent e7bda4c5e4
commit 404681f395
6 changed files with 29 additions and 1 deletions

View file

@ -1,7 +1,8 @@
BASE_DIR = "resources/scripts/"
dofile(BASE_DIR.."commands/Commands.lua")
dofile(BASE_DIR.."actions/Actions.lua")
dofile(BASE_DIR.."commands/Commands.lua")
dofile(BASE_DIR.."effects/Effects.lua")
dofile(BASE_DIR.."events/Events.lua")
dofile(BASE_DIR.."items/Items.lua")
dofile(BASE_DIR.."Global.lua")

View file

@ -0,0 +1,2 @@
registerEffect(50, "Sprint.lua")
registerEffect(4209, "Jog.lua")

View file

@ -0,0 +1,7 @@
function onGain(player)
-- it does nothing
end
function onLose(player)
-- it does nothing
end

View file

@ -0,0 +1,9 @@
EFFECT_JOG = 4029
function onGain(player)
-- it does nothing
end
function onLose(player)
player:gain_effect(EFFECT_JOG)
end

View file

@ -49,6 +49,7 @@ pub struct ExtraLuaState {
pub event_scripts: HashMap<u32, String>,
pub command_scripts: HashMap<String, String>,
pub gm_command_scripts: HashMap<u32, String>,
pub effect_scripts: HashMap<u32, String>,
}
#[derive(Debug, Default, Clone)]

View file

@ -620,6 +620,13 @@ pub fn load_init_script(lua: &mut Lua) -> mlua::Result<()> {
Ok(())
})?;
let register_effects_func =
lua.create_function(|lua, (command_type, status_script): (u32, String)| {
let mut state = lua.app_data_mut::<ExtraLuaState>().unwrap();
let _ = state.effect_scripts.insert(command_type, status_script);
Ok(())
})?;
let get_login_message_func = lua.create_function(|_, _: ()| {
let config = get_config();
Ok(config.world.login_message)
@ -632,6 +639,7 @@ 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("registerEffect", register_effects_func)?;
lua.globals()
.set("getLoginMessage", get_login_message_func)?;