Skip to content

feat: allow lua scripts to insert ScriptComponent #359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2025
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
3 changes: 2 additions & 1 deletion crates/bevy_mod_scripting_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use error::ScriptError;
use event::ScriptCallbackEvent;
use handler::{CallbackSettings, HandlerFn};
use runtime::{initialize_runtime, Runtime, RuntimeContainer, RuntimeInitializer, RuntimeSettings};
use script::{ScriptId, Scripts, StaticScripts};
use script::{ScriptComponent, ScriptId, Scripts, StaticScripts};

pub mod asset;
pub mod bindings;
Expand Down Expand Up @@ -326,6 +326,7 @@ fn register_types(app: &mut App) {
app.register_type::<ScriptValue>();
app.register_type::<ScriptTypeRegistration>();
app.register_type::<ReflectReference>();
app.register_type::<ScriptComponent>();
}

/// Trait for adding a runtime initializer to an app
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_mod_scripting_core/src/script.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Script related types, functions and components

use crate::{asset::ScriptAsset, IntoScriptPluginParams};
use bevy::prelude::ReflectComponent;
use bevy::{asset::Handle, ecs::system::Resource, reflect::Reflect, utils::HashSet};
use parking_lot::Mutex;
use std::{borrow::Cow, collections::HashMap, ops::Deref, sync::Arc};
Expand All @@ -11,7 +12,7 @@ use std::{borrow::Cow, collections::HashMap, ops::Deref, sync::Arc};
pub type ScriptId = Cow<'static, str>;

#[derive(bevy::ecs::component::Component, Reflect, Clone)]

#[reflect(Component)]
/// A component which identifies the scripts existing on an entity.
///
/// Event handlers search for components with this component to figure out which scripts to run and on which entities.
Expand Down
Loading