diff --git a/src/runtimes/lua.rs b/src/runtimes/lua.rs index 7ce1745..9d0962b 100644 --- a/src/runtimes/lua.rs +++ b/src/runtimes/lua.rs @@ -59,6 +59,12 @@ impl FromLua<'_> for BevyEntity { #[derive(Debug, Clone, Copy)] pub struct BevyVec3(pub Vec3); +impl BevyVec3 { + pub fn new(x: f32, y: f32, z: f32) -> Self { + BevyVec3(Vec3 { x, y, z }) + } +} + impl UserData for BevyVec3 {} impl FromLua<'_> for BevyVec3 { diff --git a/tests/tests.rs b/tests/tests.rs index 81894fe..fc2ecb2 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -554,6 +554,15 @@ mod rhai_tests { #[derive(Clone)] struct BevyEntity(Entity); + #[derive(Clone)] + struct BevyVec3(Vec3); + + impl BevyVec3 { + fn new(x: f32, y: f32, z: f32) -> Self { + Self(Vec3 { x, y, z }) + } + } + impl AssertStateKeyValue for RhaiRuntime { type ScriptData = RhaiScriptData; @@ -576,7 +585,7 @@ mod rhai_tests { } } - scripting_tests!(RhaiRuntime, "rhai", "rhai", BevyEntity); + scripting_tests!(RhaiRuntime, "rhai", "rhai", BevyEntity, BevyVec3); } #[cfg(feature = "lua")] @@ -618,7 +627,7 @@ mod lua_tests { } } - scripting_tests!(LuaRuntime, "lua", "lua", BevyEntity); + scripting_tests!(LuaRuntime, "lua", "lua", BevyEntity, BevyVec3); } #[cfg(feature = "ruby")]