diff --git a/Cargo.toml b/Cargo.toml index 486ed4c..fde6cc8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,10 @@ license = "MIT OR Apache-2.0" description = "Run embedded Luau scripts which manipulate the DOM." authors = ["Rhys Lloyd "] +[features] +default=["run-service"] +run-service=[] + [dependencies] glam = "0.29.0" mlua = { version = "0.10.0-beta", features = ["luau"] } diff --git a/src/lib.rs b/src/lib.rs index 669c126..fd38760 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ pub mod runner; pub mod context; +#[cfg(feature="run-service")] pub(crate) mod scheduler; #[cfg(test)] diff --git a/src/runner/runner.rs b/src/runner/runner.rs index 571a978..39fa25a 100644 --- a/src/runner/runner.rs +++ b/src/runner/runner.rs @@ -1,4 +1,5 @@ use crate::context::Context; +#[cfg(feature="run-service")] use crate::scheduler::scheduler_mut; pub struct Runner{ @@ -30,6 +31,7 @@ fn init(lua:&mlua::Lua)->mlua::Result<()>{ //global environment let globals=lua.globals(); + #[cfg(feature="run-service")] crate::scheduler::set_globals(lua,&globals)?; super::r#enum::set_globals(lua,&globals)?; super::color3::set_globals(lua,&globals)?; @@ -62,6 +64,7 @@ impl Runner{ } //this makes set_app_data shut up about the lifetime self.lua.set_app_data::<&'static mut rbx_dom_weak::WeakDom>(unsafe{core::mem::transmute(&mut context.dom)}); + #[cfg(feature="run-service")] self.lua.set_app_data::(crate::scheduler::Scheduler::default()); Ok(Runnable{ lua:self.lua, @@ -78,6 +81,7 @@ pub struct Runnable<'a>{ impl Runnable<'_>{ pub fn drop_context(self)->Runner{ self.lua.remove_app_data::<&'static mut rbx_dom_weak::WeakDom>(); + #[cfg(feature="run-service")] self.lua.remove_app_data::(); Runner{ lua:self.lua, @@ -95,11 +99,13 @@ impl Runnable<'_>{ // No need to schedule the thread here Ok(()) } + #[cfg(feature="run-service")] pub fn has_scheduled_threads(&self)->Result{ scheduler_mut(&self.lua,|scheduler| Ok(scheduler.has_scheduled_threads()) ) } + #[cfg(feature="run-service")] pub fn game_tick(&self)->Result<(),mlua::Error>{ if let Some(threads)=scheduler_mut(&self.lua,|scheduler|Ok(scheduler.tick_threads()))?{ for thread in threads{