p2p/src/plugin.rs
Lucas Schwiderski eb67616eb6
All checks were successful
build Build for the target platform
lint/clippy Check for common mistakes and opportunities for code improvement
Rework plugin structure
Also implements logging through the common `log` macros.
2025-05-08 01:44:35 +02:00

30 lines
674 B
Rust

use log::info;
use crate::{LUA, MODULE_NAME, PLUGIN_NAME, global, lua};
pub(crate) struct Plugin {}
impl Plugin {
pub fn new() -> Self {
Self {}
}
pub fn setup_game(&self) {
info!("[setup_game] Hello, world! This is {}!", PLUGIN_NAME);
let lua = global!(LUA);
lua.add_module_function(MODULE_NAME, "do_something", lua::do_something);
}
pub fn shutdown_game(&self) {
info!("[shutdown_game] Goodbye, world!");
}
pub fn update_game(&self, _dt: f32) {}
}
impl std::fmt::Debug for Plugin {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("PluginApi")
}
}