Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
[package]
name = "bevy_mod_scripting"
description = "Multi language scripting in Bevy"
include = ["readme.md", "/src", "/examples", "/assets", "LICENSE", "/badges"]
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
keywords.workspace = true
categories.workspace = true
readme.workspace = true

[workspace.package]
version = "0.15.1"
authors = ["Maksymilian Mozolewski <[email protected]>"]
edition = "2024"
authors = ["Maksymilian Mozolewski <[email protected]>"]
license = "MIT OR Apache-2.0"
description = "Multi language scripting in Bevy"
repository = "https://github.com/makspll/bevy_mod_scripting"
homepage = "https://github.com/makspll/bevy_mod_scripting"
repository = "https://github.com/makspll/bevy_mod_scripting"
keywords = ["bevy", "gamedev", "scripting", "lua"]
categories = ["game-development"]
readme = "readme.md"
include = ["readme.md", "/src", "/examples", "/assets", "LICENSE", "/badges"]

[lib]
name = "bevy_mod_scripting"
Expand Down Expand Up @@ -292,6 +303,10 @@ name = "docgen"
path = "examples/docgen.rs"
required-features = []

[[example]]
name = "runscript"
path = "examples/run-script.rs"

[workspace.lints.clippy]
panic = "deny"
unwrap_used = "deny"
Expand Down
37 changes: 19 additions & 18 deletions assets/tests/add_system/added_systems_run_in_parallel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,26 @@ digraph {
node_2 [label="bevy_asset::assets::Assets<()>::asset_events"];
node_3 [label="bevy_asset::assets::Assets<bevy_mod_scripting_asset::script_asset::ScriptAsset>::asset_events"];
node_4 [label="bevy_mod_scripting_bindings::allocator::garbage_collector"];
node_5 [label="script_integration_test_harness::dummy_before_post_update_system"];
node_6 [label="script_integration_test_harness::dummy_post_update_system"];
node_7 [label="on_test_post_update"];
node_8 [label="custom_system_a"];
node_9 [label="custom_system_b"];
node_10 [label="SystemSet AssetEvents"];
node_11 [label="SystemSet GarbageCollection"];
node_12 [label="SystemSet ScriptSystem(custom_system_a)"];
node_13 [label="SystemSet ScriptSystem(custom_system_b)"];
node_0 -> node_10 [color=red, label="child of", arrowhead=diamond];
node_1 -> node_10 [color=red, label="child of", arrowhead=diamond];
node_2 -> node_10 [color=red, label="child of", arrowhead=diamond];
node_3 -> node_10 [color=red, label="child of", arrowhead=diamond];
node_4 -> node_11 [color=red, label="child of", arrowhead=diamond];
node_8 -> node_12 [color=red, label="child of", arrowhead=diamond];
node_5 [label="bevy_mod_scripting_core::handler::script_error_logger"];
node_6 [label="script_integration_test_harness::dummy_before_post_update_system"];
node_7 [label="script_integration_test_harness::dummy_post_update_system"];
node_8 [label="on_test_post_update"];
node_9 [label="custom_system_a"];
node_10 [label="custom_system_b"];
node_11 [label="SystemSet AssetEvents"];
node_12 [label="SystemSet GarbageCollection"];
node_13 [label="SystemSet ScriptSystem(custom_system_a)"];
node_14 [label="SystemSet ScriptSystem(custom_system_b)"];
node_0 -> node_11 [color=red, label="child of", arrowhead=diamond];
node_1 -> node_11 [color=red, label="child of", arrowhead=diamond];
node_2 -> node_11 [color=red, label="child of", arrowhead=diamond];
node_3 -> node_11 [color=red, label="child of", arrowhead=diamond];
node_4 -> node_12 [color=red, label="child of", arrowhead=diamond];
node_9 -> node_13 [color=red, label="child of", arrowhead=diamond];
node_5 -> node_6 [color=blue, label="runs before", arrowhead=normal];
node_7 -> node_8 [color=blue, label="runs before", arrowhead=normal];
node_7 -> node_9 [color=blue, label="runs before", arrowhead=normal];
node_10 -> node_14 [color=red, label="child of", arrowhead=diamond];
node_6 -> node_7 [color=blue, label="runs before", arrowhead=normal];
node_8 -> node_9 [color=blue, label="runs before", arrowhead=normal];
node_8 -> node_10 [color=blue, label="runs before", arrowhead=normal];
}
]]
assert_str_eq(dot_graph, expected_dot_graph, "Expected the schedule graph to match the expected graph")
Expand Down
37 changes: 19 additions & 18 deletions assets/tests/add_system/added_systems_run_in_parallel.rhai
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,26 @@ digraph {
node_2 [label="bevy_asset::assets::Assets<()>::asset_events"];
node_3 [label="bevy_asset::assets::Assets<bevy_mod_scripting_asset::script_asset::ScriptAsset>::asset_events"];
node_4 [label="bevy_mod_scripting_bindings::allocator::garbage_collector"];
node_5 [label="script_integration_test_harness::dummy_before_post_update_system"];
node_6 [label="script_integration_test_harness::dummy_post_update_system"];
node_7 [label="on_test_post_update"];
node_8 [label="custom_system_a"];
node_9 [label="custom_system_b"];
node_10 [label="SystemSet AssetEvents"];
node_11 [label="SystemSet GarbageCollection"];
node_12 [label="SystemSet ScriptSystem(custom_system_a)"];
node_13 [label="SystemSet ScriptSystem(custom_system_b)"];
node_0 -> node_10 [color=red, label="child of", arrowhead=diamond];
node_1 -> node_10 [color=red, label="child of", arrowhead=diamond];
node_2 -> node_10 [color=red, label="child of", arrowhead=diamond];
node_3 -> node_10 [color=red, label="child of", arrowhead=diamond];
node_4 -> node_11 [color=red, label="child of", arrowhead=diamond];
node_8 -> node_12 [color=red, label="child of", arrowhead=diamond];
node_5 [label="bevy_mod_scripting_core::handler::script_error_logger"];
node_6 [label="script_integration_test_harness::dummy_before_post_update_system"];
node_7 [label="script_integration_test_harness::dummy_post_update_system"];
node_8 [label="on_test_post_update"];
node_9 [label="custom_system_a"];
node_10 [label="custom_system_b"];
node_11 [label="SystemSet AssetEvents"];
node_12 [label="SystemSet GarbageCollection"];
node_13 [label="SystemSet ScriptSystem(custom_system_a)"];
node_14 [label="SystemSet ScriptSystem(custom_system_b)"];
node_0 -> node_11 [color=red, label="child of", arrowhead=diamond];
node_1 -> node_11 [color=red, label="child of", arrowhead=diamond];
node_2 -> node_11 [color=red, label="child of", arrowhead=diamond];
node_3 -> node_11 [color=red, label="child of", arrowhead=diamond];
node_4 -> node_12 [color=red, label="child of", arrowhead=diamond];
node_9 -> node_13 [color=red, label="child of", arrowhead=diamond];
node_5 -> node_6 [color=blue, label="runs before", arrowhead=normal];
node_7 -> node_8 [color=blue, label="runs before", arrowhead=normal];
node_7 -> node_9 [color=blue, label="runs before", arrowhead=normal];
node_10 -> node_14 [color=red, label="child of", arrowhead=diamond];
node_6 -> node_7 [color=blue, label="runs before", arrowhead=normal];
node_8 -> node_9 [color=blue, label="runs before", arrowhead=normal];
node_8 -> node_10 [color=blue, label="runs before", arrowhead=normal];
}`;

assert_str_eq.call(dot_graph, expected_dot_graph, "Expected the schedule graph to match the expected graph");
Expand Down
2 changes: 1 addition & 1 deletion assets/tests/display/print_value_by_default.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ReflectReference {
),
base_id: Resource(
ComponentId(
"test_utils::test_data::TestResource",
test_utils::test_data::TestResource,
),
),
},
Expand Down
18 changes: 9 additions & 9 deletions crates/bevy_mod_scripting_asset/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[package]
name = "bevy_mod_scripting_asset"
version = "0.15.1"
authors = ["Maksymilian Mozolewski <[email protected]>"]
edition = "2024"
license = "MIT OR Apache-2.0"
description = "Core traits and structures required for other parts of bevy_mod_scripting"
repository = "https://github.com/makspll/bevy_mod_scripting"
homepage = "https://github.com/makspll/bevy_mod_scripting"
categories = ["game-development"]
readme = "readme.md"

version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
keywords.workspace = true
categories.workspace = true
readme.workspace = true

[dependencies]
bevy_reflect = { workspace = true }
Expand Down
3 changes: 0 additions & 3 deletions crates/bevy_mod_scripting_asset/readme.md

This file was deleted.

18 changes: 12 additions & 6 deletions crates/bevy_mod_scripting_asset/src/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ pub enum Language {

impl std::fmt::Display for Language {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Language::Rhai => "Rhai".fmt(f),
Language::Lua => "Lua".fmt(f),
Language::Rune => "Rune".fmt(f),
Language::External(cow) => cow.fmt(f),
Language::Unknown => "Unknown".fmt(f),
Cow::<'static, str>::from(self).fmt(f)
}
}

impl From<&Language> for Cow<'static, str> {
fn from(val: &Language) -> Self {
match val {
Language::Rhai => Cow::Borrowed("Rhai"),
Language::Lua => Cow::Borrowed("Lua"),
Language::Rune => Cow::Borrowed("Rune"),
Language::External(cow) => cow.clone(),
Language::Unknown => Cow::Borrowed("Unknown"),
}
}
}
Expand Down
19 changes: 10 additions & 9 deletions crates/bevy_mod_scripting_bindings/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[package]
name = "bevy_mod_scripting_bindings"
version = "0.15.1"
authors = ["Maksymilian Mozolewski <[email protected]>"]
edition = "2024"
license = "MIT OR Apache-2.0"
description = "Core traits and structures required for other parts of bevy_mod_scripting"
repository = "https://github.com/makspll/bevy_mod_scripting"
homepage = "https://github.com/makspll/bevy_mod_scripting"
categories = ["game-development"]
readme = "readme.md"
description = "Core traits and structures required for smoothly interfacing with other languages in a generic way"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
keywords.workspace = true
categories.workspace = true
readme.workspace = true


[dependencies]
Expand Down
28 changes: 13 additions & 15 deletions crates/bevy_mod_scripting_bindings/src/access_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,26 @@ impl DisplayWithTypeInfo for ReflectAccessId {
fn display_with_type_info(
&self,
f: &mut std::fmt::Formatter<'_>,
_type_info_provider: Option<&dyn GetTypeInfo>,
type_info_provider: Option<&dyn GetTypeInfo>,
) -> std::fmt::Result {
match self.kind {
ReflectAccessKind::ComponentOrResource => {
write!(
f,
"Component or resource: {}",
WithTypeInfo(&ComponentId::new(self.id as usize))
WithTypeInfo::new_with_opt_info(
&ComponentId::new(self.id as usize),
type_info_provider
)
)
}
ReflectAccessKind::Allocation => write!(
f,
"Allocation to: {}",
WithTypeInfo(&ReflectAllocationId::new(self.id))
WithTypeInfo::new_with_opt_info(
&ReflectAllocationId::new(self.id),
type_info_provider
)
),
ReflectAccessKind::Global => write!(f, "World(Global)"),
}
Expand Down Expand Up @@ -221,23 +227,15 @@ impl ReflectAccessId {
}
}

#[profiling::all_functions]
impl From<ComponentId> for ReflectAccessId {
fn from(value: ComponentId) -> Self {
Self {
kind: ReflectAccessKind::ComponentOrResource,
id: value.index() as u64,
}
fn from(id: ComponentId) -> Self {
ReflectAccessId::for_component_id(id)
}
}

#[profiling::all_functions]
impl From<ReflectAllocationId> for ReflectAccessId {
fn from(value: ReflectAllocationId) -> Self {
Self {
kind: ReflectAccessKind::Allocation,
id: value.id(),
}
fn from(id: ReflectAllocationId) -> Self {
ReflectAccessId::for_allocation(id)
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_mod_scripting_bindings/src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ impl DebugWithTypeInfo for ReflectAllocation {
fn to_string_with_type_info(
&self,
f: &mut std::fmt::Formatter<'_>,
_type_info_provider: Option<&dyn bevy_mod_scripting_display::GetTypeInfo>,
type_info_provider: Option<&dyn bevy_mod_scripting_display::GetTypeInfo>,
) -> std::fmt::Result {
f.debug_tuple_with_type_info("ReflectAllocation")
f.debug_tuple_with_type_info("ReflectAllocation", type_info_provider)
.field(&((self.0.get() as *mut ()) as usize))
.finish()
}
Expand Down
6 changes: 4 additions & 2 deletions crates/bevy_mod_scripting_bindings/src/docgen/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ impl DisplayWithTypeInfo for FunctionArgInfo {
write!(f, "{name}: ")?;
}
let type_id = self.type_id;
WithTypeInfo(&type_id).display_with_type_info(f, type_info_provider)?;
WithTypeInfo::new_with_opt_info(&type_id, type_info_provider)
.display_with_type_info(f, type_info_provider)?;
Ok(())
}
}
Expand Down Expand Up @@ -186,7 +187,8 @@ impl DisplayWithTypeInfo for FunctionReturnInfo {
type_info_provider: Option<&dyn GetTypeInfo>,
) -> std::fmt::Result {
let type_id = self.type_id;
WithTypeInfo(&type_id).display_with_type_info(f, type_info_provider)?;
WithTypeInfo::new_with_opt_info(&type_id, type_info_provider)
.display_with_type_info(f, type_info_provider)?;
Ok(())
}
}
Expand Down
Loading
Loading