diff --git a/src/runner/instance.rs b/src/runner/instance/instance.rs similarity index 95% rename from src/runner/instance.rs rename to src/runner/instance/instance.rs index 62e52f3..5c7f66c 100644 --- a/src/runner/instance.rs +++ b/src/runner/instance/instance.rs @@ -4,7 +4,7 @@ use mlua::{FromLua,FromLuaMulti,IntoLua,IntoLuaMulti}; use rbx_types::Ref; use rbx_dom_weak::{InstanceBuilder,WeakDom}; -use super::vector3::Vector3; +use crate::runner::vector3::Vector3; pub fn set_globals(lua:&mlua::Lua,globals:&mlua::Table)->Result<(),mlua::Error>{ //class functions store @@ -253,8 +253,8 @@ impl mlua::UserData for Instance{ Some(rbx_types::Variant::Float32(val))=>return val.into_lua(lua), Some(rbx_types::Variant::Float64(val))=>return val.into_lua(lua), Some(rbx_types::Variant::Ref(val))=>return Instance::new(val).into_lua(lua), - Some(rbx_types::Variant::CFrame(cf))=>return Into::::into(cf).into_lua(lua), - Some(rbx_types::Variant::Vector3(v))=>return Into::::into(v).into_lua(lua), + Some(rbx_types::Variant::CFrame(cf))=>return Into::::into(cf).into_lua(lua), + Some(rbx_types::Variant::Vector3(v))=>return Into::::into(v).into_lua(lua), None=>(), other=>return Err(mlua::Error::runtime(format!("Instance.__index Unsupported property type instance={} index={index_str} value={other:?}",instance.name))), } @@ -319,7 +319,7 @@ impl mlua::UserData for Instance{ Ok(rbx_types::Enum::from_u32(*e.items.get(&*s.to_str()?).ok_or(mlua::Error::runtime("Invalid enum item"))?)) }, mlua::Value::UserData(any_user_data)=>{ - let e:super::r#enum::Enum=*any_user_data.borrow()?; + let e:crate::runner::r#enum::Enum=*any_user_data.borrow()?; Ok(e.into()) }, _=>Err(mlua::Error::runtime("Expected Enum")), @@ -327,7 +327,7 @@ impl mlua::UserData for Instance{ instance.properties.insert(index_str.to_owned(),rbx_types::Variant::Enum(typed_value)); }, rbx_reflection::DataType::Value(rbx_types::VariantType::Color3)=>{ - let typed_value:super::color3::Color3=*value.as_userdata().ok_or(mlua::Error::runtime("Expected Color3"))?.borrow()?; + let typed_value:crate::runner::color3::Color3=*value.as_userdata().ok_or(mlua::Error::runtime("Expected Color3"))?.borrow()?; instance.properties.insert(index_str.to_owned(),rbx_types::Variant::Color3(typed_value.into())); }, rbx_reflection::DataType::Value(rbx_types::VariantType::Bool)=>{ @@ -339,11 +339,11 @@ impl mlua::UserData for Instance{ instance.properties.insert(index_str.to_owned(),rbx_types::Variant::String(typed_value.to_owned())); }, rbx_reflection::DataType::Value(rbx_types::VariantType::NumberSequence)=>{ - let typed_value:super::number_sequence::NumberSequence=*value.as_userdata().ok_or(mlua::Error::runtime("Expected NumberSequence"))?.borrow()?; + let typed_value:crate::runner::number_sequence::NumberSequence=*value.as_userdata().ok_or(mlua::Error::runtime("Expected NumberSequence"))?.borrow()?; instance.properties.insert(index_str.to_owned(),rbx_types::Variant::NumberSequence(typed_value.into())); }, rbx_reflection::DataType::Value(rbx_types::VariantType::ColorSequence)=>{ - let typed_value:super::color_sequence::ColorSequence=*value.as_userdata().ok_or(mlua::Error::runtime("Expected ColorSequence"))?.borrow()?; + let typed_value:crate::runner::color_sequence::ColorSequence=*value.as_userdata().ok_or(mlua::Error::runtime("Expected ColorSequence"))?.borrow()?; instance.properties.insert(index_str.to_owned(),rbx_types::Variant::ColorSequence(typed_value.into())); }, other=>return Err(mlua::Error::runtime(format!("Unimplemented property type: {other:?}"))), @@ -393,7 +393,7 @@ static CLASS_FUNCTION_DATABASE:CFD=phf::phf_map!{ }), }, "Terrain"=>phf::phf_map!{ - "FillBlock"=>cf!(|_lua,_,_:(super::cframe::CFrame,Vector3,super::r#enum::Enum)|mlua::Result::Ok(())) + "FillBlock"=>cf!(|_lua,_,_:(crate::runner::cframe::CFrame,Vector3,crate::runner::r#enum::Enum)|mlua::Result::Ok(())) }, }; @@ -507,7 +507,7 @@ type LUD=phf::Map<&'static str,// Class name static LAZY_USER_DATA:LUD=phf::phf_map!{ "RunService"=>phf::phf_map!{ "RenderStepped"=>|lua|{ - lua.create_any_userdata(super::script_signal::ScriptSignal::new()) + lua.create_any_userdata(crate::runner::script_signal::ScriptSignal::new()) }, }, }; diff --git a/src/runner/instance/mod.rs b/src/runner/instance/mod.rs new file mode 100644 index 0000000..234af3d --- /dev/null +++ b/src/runner/instance/mod.rs @@ -0,0 +1,2 @@ +pub mod instance; +pub use instance::Instance; diff --git a/src/runner/runner.rs b/src/runner/runner.rs index debd1e1..7137229 100644 --- a/src/runner/runner.rs +++ b/src/runner/runner.rs @@ -37,7 +37,7 @@ fn init(lua:&mlua::Lua)->mlua::Result<()>{ super::color3::set_globals(lua,&globals)?; super::vector3::set_globals(lua,&globals)?; super::cframe::set_globals(lua,&globals)?; - super::instance::set_globals(lua,&globals)?; + super::instance::instance::set_globals(lua,&globals)?; super::number_sequence::set_globals(lua,&globals)?; super::color_sequence::set_globals(lua,&globals)?; @@ -88,7 +88,7 @@ impl Runnable<'_>{ } } pub fn run_script(&self,script:super::instance::Instance)->Result<(),Error>{ - let (name,source)=super::instance::get_name_source(&self.lua,script).map_err(Error::RustLua)?; + let (name,source)=super::instance::instance::get_name_source(&self.lua,script).map_err(Error::RustLua)?; self.lua.globals().raw_set("script",script).map_err(Error::RustLua)?; let f=self.lua.load(source.as_str()) .set_name(name).into_function().map_err(Error::RustLua)?; @@ -122,9 +122,9 @@ impl Runnable<'_>{ } #[cfg(feature="run-service")] pub fn run_service_step(&self)->Result<(),mlua::Error>{ - let render_stepped=super::instance::dom_mut(&self.lua,|dom|{ - let run_service=super::instance::find_first_child_of_class(dom,dom.root(),"RunService").ok_or_else(||mlua::Error::runtime("RunService missing"))?; - super::instance::instance_value_store_mut(&self.lua,|instance_value_store|{ + let render_stepped=super::instance::instance::dom_mut(&self.lua,|dom|{ + let run_service=super::instance::instance::find_first_child_of_class(dom,dom.root(),"RunService").ok_or_else(||mlua::Error::runtime("RunService missing"))?; + super::instance::instance::instance_value_store_mut(&self.lua,|instance_value_store|{ //unwrap because I trust my find_first_child_of_class function to let mut instance_values=instance_value_store.get_or_create_instance_values(run_service).ok_or_else(||mlua::Error::runtime("RunService InstanceValues missing"))?; let render_stepped=instance_values.get_or_create_value(&self.lua,"RenderStepped")?;