diff --git a/crates/bevy_script_api/src/core_providers.rs b/crates/bevy_script_api/src/core_providers.rs index 7998be9b..0e1196ea 100644 --- a/crates/bevy_script_api/src/core_providers.rs +++ b/crates/bevy_script_api/src/core_providers.rs @@ -1,6 +1,6 @@ use crate::lua::RegisterForeignLuaType; -pub struct CoreBevyAPIProvider; +pub struct LuaCoreBevyAPIProvider; #[derive(Default)] pub(crate) struct CoreBevyGlobals; @@ -28,7 +28,7 @@ impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for CoreBevyGlobals { } } -impl bevy_mod_scripting_core::hosts::APIProvider for CoreBevyAPIProvider { +impl bevy_mod_scripting_core::hosts::APIProvider for LuaCoreBevyAPIProvider { type APITarget = std::sync::Mutex; type ScriptContext = std::sync::Mutex; type DocTarget = bevy_mod_scripting_lua::docs::LuaDocFragment; diff --git a/crates/bevy_script_api/src/lib.rs b/crates/bevy_script_api/src/lib.rs index 15b4d6dd..eee50f03 100644 --- a/crates/bevy_script_api/src/lib.rs +++ b/crates/bevy_script_api/src/lib.rs @@ -23,9 +23,9 @@ pub use {script_ref::*, sub_reflect::*}; pub mod prelude { #[cfg(feature = "lua")] pub use crate::{ - core_providers::CoreBevyAPIProvider, + core_providers::LuaCoreBevyAPIProvider, lua::{std::LuaVec, FromLuaProxy, IntoLuaProxy, LuaProxyable, ReflectLuaProxyable}, - providers::BevyAPIProvider, + providers::LuaBevyAPIProvider, LuaProxy, }; diff --git a/crates/bevy_script_api/src/providers/mod.rs b/crates/bevy_script_api/src/providers/mod.rs index e11801a6..62a19bbb 100644 --- a/crates/bevy_script_api/src/providers/mod.rs +++ b/crates/bevy_script_api/src/providers/mod.rs @@ -12,8 +12,8 @@ pub(crate) mod bevy_window; pub(crate) mod bevy_reflect; extern crate self as bevy_script_api; use bevy_mod_scripting_core::docs::DocFragment; -pub struct BevyAPIProvider; -impl bevy_mod_scripting_core::hosts::APIProvider for BevyAPIProvider { +pub struct LuaBevyAPIProvider; +impl bevy_mod_scripting_core::hosts::APIProvider for LuaBevyAPIProvider { type APITarget = std::sync::Mutex; type ScriptContext = std::sync::Mutex; type DocTarget = bevy_mod_scripting_lua::docs::LuaDocFragment; diff --git a/examples/lua/bevy_api.rs b/examples/lua/bevy_api.rs index 41f8e248..259081e6 100644 --- a/examples/lua/bevy_api.rs +++ b/examples/lua/bevy_api.rs @@ -30,8 +30,8 @@ fn main() -> std::io::Result<()> { .register_foreign_lua_type::>() .register_foreign_lua_type::>>() .add_script_host::>(PostUpdate) - .add_api_provider::>(Box::new(BevyAPIProvider)) - .add_api_provider::>(Box::new(CoreBevyAPIProvider)) + .add_api_provider::>(Box::new(LuaBevyAPIProvider)) + .add_api_provider::>(Box::new(LuaCoreBevyAPIProvider)) .add_systems(Startup, |world: &mut World| { diff --git a/examples/lua/console_integration.rs b/examples/lua/console_integration.rs index f16fafc7..1b64efe3 100644 --- a/examples/lua/console_integration.rs +++ b/examples/lua/console_integration.rs @@ -167,7 +167,7 @@ fn main() -> std::io::Result<()> { // choose and register the script hosts you want to use .add_script_host::>(PostUpdate) .add_api_provider::>(Box::new(LuaAPIProvider)) - .add_api_provider::>(Box::new(CoreBevyAPIProvider)) + .add_api_provider::>(Box::new(LuaCoreBevyAPIProvider)) .add_script_handler::, 0, 0>(PostUpdate) // add your systems .add_systems(Update, trigger_on_update_lua) diff --git a/examples/lua/documentation_gen.rs b/examples/lua/documentation_gen.rs index 23ba6fd7..12e8e59e 100644 --- a/examples/lua/documentation_gen.rs +++ b/examples/lua/documentation_gen.rs @@ -86,8 +86,8 @@ fn main() -> std::io::Result<()> { // add the providers and script host .add_script_host::>(PostUpdate) .add_api_provider::>(Box::new(LuaAPIProvider)) - .add_api_provider::>(Box::new(CoreBevyAPIProvider)) - .add_api_provider::>(Box::new(BevyAPIProvider)) + .add_api_provider::>(Box::new(LuaCoreBevyAPIProvider)) + .add_api_provider::>(Box::new(LuaBevyAPIProvider)) // this needs to be placed after any `add_api_provider` and `add_script_host` calls // it will generate `doc` and `types` folders under `assets/scripts` containing the documentation and teal declaration files // respectively. See example asset folder to see how they look like. The `teal_file.tl` script in example assets shows the usage of one of those diff --git a/examples/lua/game_of_life.rs b/examples/lua/game_of_life.rs index 8aceeebe..ed844775 100644 --- a/examples/lua/game_of_life.rs +++ b/examples/lua/game_of_life.rs @@ -209,7 +209,7 @@ fn main() -> std::io::Result<()> { .add_systems(FixedUpdate, send_on_update.after(update_rendered_state)) .add_systems(FixedUpdate, script_event_handler::, 0, 1>) .add_script_host::>(PostUpdate) - .add_api_provider::>(Box::new(CoreBevyAPIProvider)) + .add_api_provider::>(Box::new(LuaCoreBevyAPIProvider)) .add_api_provider::>(Box::new(LifeAPI)); app.run(); diff --git a/examples/wrappers.rs b/examples/wrappers.rs index 3ef252ff..734c9f9b 100644 --- a/examples/wrappers.rs +++ b/examples/wrappers.rs @@ -64,7 +64,7 @@ fn main() -> std::io::Result<()> { .add_script_host::>(PostUpdate) .register_type::() .init_resource::() - .add_api_provider::>(Box::new(CoreBevyAPIProvider)) + .add_api_provider::>(Box::new(LuaCoreBevyAPIProvider)) .add_systems(Startup, |world: &mut World| { world.insert_resource(MyProxiedStruct { my_string: "I was retrieved from the world".to_owned(), diff --git a/readme.md b/readme.md index 7ef2c343..99046f6c 100644 --- a/readme.md +++ b/readme.md @@ -188,7 +188,7 @@ Register your API providers like so: app.add_plugins(DefaultPlugins) .add_plugins(ScriptingPlugin) .add_script_host::>(PostUpdate) - .add_api_provider::>(Box::new(LuaAPIProvider)) + .add_api_provider::>(Box::new(LuaAPI)) //... ``` The `APIProvider` interface also includes `setup_script` and `get_doc_fragment` methods. By default, these methods do not perform any operation. However, they can be utilized for specific purposes. For instance, `get_doc_fragment` can be used to generate documentation (refer to examples), and `setup_script` can ensure a one-time setup per script, like setting up a Lua package path. @@ -210,7 +210,8 @@ fn main() -> std::io::Result<()> { .add_script_host::>(PostUpdate) // Note: This is a noop in optimized builds unless the `doc_always` feature is enabled! // this will pickup any API providers added *BEFOREHAND* like this one - // .add_api_provider::>(Box::new(LuaAPIProvider)) + .add_api_provider::>(Box::new(LuaBevyAPIProvider)) + .add_api_provider::>(Box::new(LuaCoreBevyAPIProvider)) .update_documentation::>() .add_script_handler::, 0, 0>(PostUpdate); diff --git a/src/documentation/main.rs b/src/documentation/main.rs index 320dada3..d7802bea 100644 --- a/src/documentation/main.rs +++ b/src/documentation/main.rs @@ -17,8 +17,8 @@ fn main() { "lua" => { #[cfg(all(feature = "lua", feature = "lua_script_api"))] app.add_script_host::>(PostUpdate) - .add_api_provider::>(Box::new(CoreBevyAPIProvider)) - .add_api_provider::>(Box::new(BevyAPIProvider)) + .add_api_provider::>(Box::new(LuaCoreBevyAPIProvider)) + .add_api_provider::>(Box::new(LuaBevyAPIProvider)) .update_documentation::>(); #[cfg(any(not(feature = "lua"), not(feature = "lua_script_api")))]