1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
pub mod lua;

use bones_asset::UntypedHandle;
use bones_lib::prelude::*;

/// The prelude.
pub mod prelude {
    pub use super::{lua::*, ScriptingGamePlugin};
    pub(crate) use bones_asset::prelude::*;
    pub(crate) use bones_lib::prelude::*;
}

/// Scripting plugin for the bones framework.
pub struct ScriptingGamePlugin {
    pub enable_lua: bool,
}

impl Default for ScriptingGamePlugin {
    fn default() -> Self {
        Self { enable_lua: true }
    }
}

impl GamePlugin for ScriptingGamePlugin {
    fn install(self, game: &mut Game) {
        UntypedHandle::register_schema();

        if self.enable_lua {
            game.install_plugin(lua::lua_game_plugin);
        }
    }
}