Your first native mod
A native mod is one flat Rust project that implements mod_api::Hooks, built by the launcher into the game it runs
in. You need the launcher and a Horizon commit to build against.
-
Make the project:
cargo horizon-mod new my_mod --template nativeIt writes
horizon-mod.toml(the manifest, with the exact build pins under[native]),Cargo.tomlandsrc/lib.rs, which implements one hook. -
Look at the hook. Each method of
Hooksis a hook point; implement the ones the mod needs. Everyimpl Hookscarries#[mod_api::horizon_mod], which subscribes the mod to just the methods in that block:#[mod_api::horizon_mod]
impl Hooks for Mod { fn server_tick(&self, host: &mut dyn ServerHost, : &mut ServerTickEvent<'>) { let _ = count(host); } }
3. Build and run it in the launcher: `horizon-launcher native-build . --instance <instance> --trust-native-code`.
Add `--profile developer` while developing for an unoptimized game crate. The choice is remembered for that instance.
Next: [Native mods](../how-to/native-mods.md) for what the launcher does, [Trait mods](../concepts/trait-mods.md)
for Parts and attachments, and [Injections](../injections.md) for the moment no hook covers.