Context::script_singleton constructor for running a single script from cli

This commit is contained in:
Quaternions 2024-09-28 12:32:19 -07:00
parent 72874d450f
commit 4a939e74d1

View File

@ -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)}
}