You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I.e. scripts which do get attached to entities, but simply always get executed on each callback regardless of entity.
Should be easier to add, perhaps with a command, AddStaticScript which will add the script ID to a collection of scripts to be considered at each event handler
/// Create a new resource that holds the static scripts' ids#[derive(Resource,Default,Deref,DerefMut)]pubstructStaticScripts(Vec<ScriptId>);/// The base ScriptingPlugin adds the resource/// That way we don't need to repeat it for every language we want to impl/// scripting forimplPluginforScriptingPlugin{fnbuild(&self,app:&mutApp){
app
.init_resource::<StaticScripts>()
...
;}}/// A utility traitpubtraitAddStaticScript{fnadd_static_script(&mutself,path:&str);}implAddStaticScriptforWorld{fnadd_static_script(&mutself,path:&str){self.resource_scope(|_,mutstatic:Mut<StaticScripts>| static.push(path.into()));}}/// Same for App, which fetches the world and calls the above method, and make a custom command that does the same in the apply method
Activity
[-]`resource` scripts[/-][+]`Resource`-like scripts[/+]Joakker commentedon Feb 5, 2025
Here's how I'd do it