Skip to content

Commit

Permalink
chore: First pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
shanecelis committed Aug 19, 2024
1 parent c497b43 commit 26d7678
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 32 deletions.
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ bevy_script_api = { path = "crates/bevy_script_api", version = "0.6.0", optional


[workspace.dependencies]
bevy = { version = "=0.13.1", default-features = false }
bevy = { version = "0.14", default-features = false }
bevy_mod_scripting_core = { path = "crates/bevy_mod_scripting_core", version = "0.6.0" }
bevy_mod_scripting_common = { path = "crates/bevy_mod_scripting_common", version = "0.6.0" }

[dev-dependencies]
bevy = { workspace = true, default-features = true }
clap = { version = "4.1", features = ["derive"] }
rand = "0.8.5"
bevy_console = "0.11.1"
# bevy_console = "0.11.1"
rhai-rand = "0.1"

[workspace]
Expand Down Expand Up @@ -118,7 +118,7 @@ required-features = [
"lua54",
"lua_script_api",
"bevy/file_watcher",
"bevy/multi-threaded",
"bevy/multi_threaded",
]

[[example]]
Expand All @@ -128,7 +128,7 @@ required-features = [
"rhai",
"rhai_script_api",
"bevy/file_watcher",
"bevy/multi-threaded",
"bevy/multi_threaded",
]

[[example]]
Expand All @@ -143,7 +143,7 @@ required-features = [
"lua54",
"lua_script_api",
"bevy/file_watcher",
"bevy/multi-threaded",
"bevy/multi_threaded",
]

[[example]]
Expand All @@ -153,7 +153,7 @@ required-features = [
"rhai",
"rhai_script_api",
"bevy/file_watcher",
"bevy/multi-threaded",
"bevy/multi_threaded",
]

[[example]]
Expand Down
4 changes: 2 additions & 2 deletions check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ CURRENT_DIR=$(basename "$PWD")
if [[ "$CURRENT_DIR" == "bevy_api_gen" ]]; then
cargo clippy --all-targets --message-format=json
else
cargo clippy --workspace --all-targets --message-format=json --features="lua54 lua_script_api rhai rhai_script_api teal rune bevy/file_watcher bevy/multi-threaded"
fi
cargo clippy --workspace --all-targets --message-format=json --features="lua54 lua_script_api rhai rhai_script_api teal rune bevy/file_watcher bevy/multi_threaded"
fi
2 changes: 1 addition & 1 deletion crates/bevy_api_gen/Cargo.bootstrap.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ edition = "2021"

[dependencies]
mlua = { version = "0.9.2", features = ["lua54", "vendored", "send", "macros"] }
bevy_reflect = { version = "0.13.1", features = ["bevy", "bevy_math"] }
bevy_reflect = { version = "0.14", features = ["bevy", "bevy_math"] }

[workspace]
4 changes: 2 additions & 2 deletions crates/bevy_mod_scripting_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl GenDocumentation for App {
#[cfg(any(debug_assertions, feature = "doc_always"))]
{
info!("Generating documentation");
let w = &mut self.world;
let w = &mut self.world_mut();
let providers: &APIProviders<T> = w.resource();
if let Err(e) = providers.gen_all() {
error!("{}", e);
Expand Down Expand Up @@ -137,7 +137,7 @@ impl AddScriptApiProvider for App {
>,
) -> &mut Self {
provider.register_with_app(self);
let w = &mut self.world;
let w = &mut self.world_mut();
let providers: &mut APIProviders<T> = &mut w.resource_mut();
providers.providers.push(provider);
self
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_script_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ bevy = { workspace = true, default-features = false, features = [
"bevy_text",
"bevy_sprite",
"file_watcher",
"multi-threaded",
"multi_threaded",
] }
bevy_mod_scripting_core = { workspace = true }
parking_lot = "0.12.1"
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_script_api/src/common/bevy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use bevy::{
ecs::{
component::ComponentId,
query::QueryBuilder,
system::Command,
world::{EntityRef, World},
world::{EntityRef, World, Command},
},
prelude::{
AppTypeRegistry, BuildWorldChildren, Children, DespawnChildrenRecursive, DespawnRecursive,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_script_api/src/lua/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl RegisterForeignLuaType for App {
&mut self,
) -> &mut Self {
{
let registry = self.world.resource_mut::<AppTypeRegistry>();
let registry = self.world_mut().resource_mut::<AppTypeRegistry>();
let mut registry = registry.write();

let user_data = <ReflectLuaProxyable as FromType<T>>::from_type();
Expand Down
16 changes: 8 additions & 8 deletions crates/bevy_script_api/src/providers/bevy_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ struct TouchPhase {}
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
#[proxy(
derive(clone),
remote = "bevy::input::touchpad::TouchpadMagnify",
remote = "bevy::input::touch::TouchpadMagnify",
functions[r#"
#[lua(
Expand All @@ -722,13 +722,13 @@ struct TouchPhase {}
composite = "eq",
metamethod = "Eq",
)]
fn eq(&self, #[proxy] other: &touchpad::TouchpadMagnify) -> bool;
fn eq(&self, #[proxy] other: &touch::TouchpadMagnify) -> bool;
"#,
r#"
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
fn clone(&self) -> bevy::input::touchpad::TouchpadMagnify;
fn clone(&self) -> bevy::input::touch::TouchpadMagnify;
"#,
r#"
Expand All @@ -742,7 +742,7 @@ struct TouchpadMagnify(f32);
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
#[proxy(
derive(clone),
remote = "bevy::input::touchpad::TouchpadRotate",
remote = "bevy::input::touch::TouchpadRotate",
functions[r#"
#[lua(
Expand All @@ -751,13 +751,13 @@ struct TouchpadMagnify(f32);
composite = "eq",
metamethod = "Eq",
)]
fn eq(&self, #[proxy] other: &touchpad::TouchpadRotate) -> bool;
fn eq(&self, #[proxy] other: &touch::TouchpadRotate) -> bool;
"#,
r#"
#[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
fn clone(&self) -> bevy::input::touchpad::TouchpadRotate;
fn clone(&self) -> bevy::input::touch::TouchpadRotate;
"#,
r#"
Expand Down Expand Up @@ -1525,8 +1525,8 @@ impl bevy_mod_scripting_core::hosts::APIProvider for BevyInputAPIProvider {
app.register_foreign_lua_type::<bevy::input::mouse::MouseWheel>();
app.register_foreign_lua_type::<bevy::input::touch::ForceTouch>();
app.register_foreign_lua_type::<bevy::input::touch::TouchPhase>();
app.register_foreign_lua_type::<bevy::input::touchpad::TouchpadMagnify>();
app.register_foreign_lua_type::<bevy::input::touchpad::TouchpadRotate>();
app.register_foreign_lua_type::<bevy::input::touch::TouchpadMagnify>();
app.register_foreign_lua_type::<bevy::input::touch::TouchpadRotate>();
app.register_foreign_lua_type::<bevy::input::gamepad::AxisSettings>();
app.register_foreign_lua_type::<bevy::input::gamepad::ButtonAxisSettings>();
app.register_foreign_lua_type::<bevy::input::gamepad::ButtonSettings>();
Expand Down
2 changes: 1 addition & 1 deletion crates/languages/bevy_mod_scripting_lua/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl AssetLoader for LuaLoader {
reader: &'a mut Reader, //bytes: &'a [u8],
_settings: &'a (),
load_context: &'a mut bevy::asset::LoadContext,
) -> bevy::asset::BoxedFuture<'a, Result<Self::Asset, Self::Error>> {
) -> bevy::utils::BoxedFuture<'a, Result<Self::Asset, Self::Error>> {
bevy::prelude::info!("lua loader invoked: {:#}", load_context.asset_path());
Box::pin(async move {
let mut bytes = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion crates/macro_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ debug = false

[dev-dependencies]
trybuild = "1.0"
bevy = { version = "0.13.1", default-features = false }
bevy = { version = "0.14", default-features = false }
bevy_mod_scripting = { path = "../../", features = [
"lua",
"lua_script_api",
Expand Down
8 changes: 4 additions & 4 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ PACKAGE=bevy_mod_scripting
TEST_NAME=
# # valgrind outputs a callgrind.out.<pid>. We can analyze this with kcachegrind
# kcachegrind
NIGHTLY_VERSION=nightly-2024-01-24
BEVY_VERSION=0.13.1
GLAM_VERSION=0.25.0
NIGHTLY_VERSION=nightly-2024-08-13
BEVY_VERSION=0.14.1
GLAM_VERSION=0.28.0
CODEGEN_PATH=${PWD}/target/codegen
BEVY_PATH=${CODEGEN_PATH}/bevy
GLAM_PATH=${CODEGEN_PATH}/glam
OUTPUT_PATH=${CODEGEN_PATH}/output
GENERATED_SRC_PATH=./crates/bevy_script_api/src/providers
GEN_BEVY_FEATURES=bevy_asset,bevy_gltf,bevy_animation,bevy_core_pipeline,bevy_ui,bevy_pbr,bevy_render,bevy_text,bevy_sprite,file_watcher,multi-threaded
GEN_BEVY_FEATURES=bevy_asset,bevy_gltf,bevy_animation,bevy_core_pipeline,bevy_ui,bevy_pbr,bevy_render,bevy_text,bevy_sprite,file_watcher,multi_threaded

build_test_in_package:
@cargo test --no-run --lib --workspace $(TEST_NAME)
Expand Down
15 changes: 12 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,19 +201,21 @@ Documentation features are exposed at runtime via the `update_documentation` bui
use bevy::prelude::*;
use bevy_mod_scripting::prelude::*;
#[cfg(feature = "lua")]
fn main() -> std::io::Result<()> {
let mut app = App::new();
app.add_plugins(DefaultPlugins)
.add_plugins(ScriptingPlugin)
.add_script_host::<LuaScriptHost<()>>(PostUpdate)
.add_plugins(ScriptingPlugin);
#[cfg(feature = "lua")]
{
app.add_script_host::<LuaScriptHost<()>>(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::<LuaScriptHost<()>>(Box::new(LuaBevyAPIProvider))
.add_api_provider::<LuaScriptHost<()>>(Box::new(LuaCoreBevyAPIProvider))
.update_documentation::<LuaScriptHost<()>>()
.add_script_handler::<LuaScriptHost<()>, 0, 0>(PostUpdate);
}
Ok(())
}
Expand Down Expand Up @@ -268,3 +270,10 @@ To see more complex applications of this library have a look at the examples:

Below is a video showcasing the game_of_life example:
[![Watch the video](https://img.youtube.com/vi/Mo9gh2g3ZHw/maxresdefault.jpg)](https://www.youtube.com/watch?v=Mo9gh2g3ZHw)

# Compatibility

| bevy_mod_scripting | bevy |
|---------------------|--------|
| 0.7 | 0.14 |
| 0.6 | 0.13.1 |

0 comments on commit 26d7678

Please sign in to comment.