From 4a939e74d1656cc183abf81d45cf23036dce3ec8 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sat, 28 Sep 2024 12:32:19 -0700 Subject: [PATCH] Context::script_singleton constructor for running a single script from cli --- src/context.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/context.rs b/src/context.rs index 6f8c8f0..1d9017b 100644 --- a/src/context.rs +++ b/src/context.rs @@ -19,6 +19,14 @@ impl Context{ pub const fn new(dom:WeakDom)->Context{ Context{dom} } + pub fn script_singleton(source:String)->(Context,crate::runner::instance::Script){ + let dom=WeakDom::new( + rbx_dom_weak::InstanceBuilder::new("Script") + .with_property("Source",rbx_types::Variant::String(source)) + ); + let script=crate::runner::instance::Script::new(dom.root_ref()); + (Context{dom},script) + } pub fn from_mut(dom:&mut WeakDom)->&mut Context{ unsafe{&mut *(dom as *mut WeakDom as *mut Context)} }