why are these early returns in between app data

This commit is contained in:
Quaternions 2024-09-21 12:53:03 -07:00
parent 4f65c35407
commit b765f4cb21

View File

@ -80,11 +80,10 @@ impl Runner{
Ok(runner) Ok(runner)
} }
pub fn run_script(&self,script:crate::script::Script,context:&mut Context)->Result<(),Error>{ pub fn run_script(&self,script:crate::script::Script,context:&mut Context)->Result<(),Error>{
let yoink=script.name_source(context); let (name,source)=script.name_source(context).map_err(Error::Script)?;
self.lua.globals().set("script",super::instance::Instance::from(script)).map_err(|error|Error::Lua{source:source.clone(),error})?;
//this makes set_app_data shut up about the lifetime //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)}); self.lua.set_app_data::<&'static mut rbx_dom_weak::WeakDom>(unsafe{core::mem::transmute(&mut context.dom)});
let (name,source)=yoink.map_err(Error::Script)?;
self.lua.globals().set("script",super::instance::Instance::from(script)).map_err(|error|Error::Lua{source:source.clone(),error})?;
let r=self.lua.load(source.as_str()) let r=self.lua.load(source.as_str())
.set_name(name) .set_name(name)
.exec().map_err(|error|Error::Lua{source,error}); .exec().map_err(|error|Error::Lua{source,error});