Instance.__index whole thing was wrong

This commit is contained in:
Quaternions 2024-10-05 21:52:12 -07:00
parent d8aacb9ed2
commit 58edaf3291

View File

@ -240,12 +240,12 @@ impl mlua::UserData for Instance{
//Find default value
.or_else(||db.find_default_property(class,index_str))
{
Some(&rbx_types::Variant::Int32(val))=>return Ok(val.into_lua(lua)),
Some(&rbx_types::Variant::Int64(val))=>return Ok(val.into_lua(lua)),
Some(&rbx_types::Variant::Float32(val))=>return Ok(val.into_lua(lua)),
Some(&rbx_types::Variant::Float64(val))=>return Ok(val.into_lua(lua)),
Some(&rbx_types::Variant::CFrame(cf))=>return Ok(Into::<super::cframe::CFrame>::into(cf).into_lua(lua)),
Some(&rbx_types::Variant::Vector3(v))=>return Ok(Into::<super::vector3::Vector3>::into(v).into_lua(lua)),
Some(&rbx_types::Variant::Int32(val))=>return val.into_lua(lua),
Some(&rbx_types::Variant::Int64(val))=>return val.into_lua(lua),
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::CFrame(cf))=>return Into::<super::cframe::CFrame>::into(cf).into_lua(lua),
Some(&rbx_types::Variant::Vector3(v))=>return Into::<super::vector3::Vector3>::into(v).into_lua(lua),
other=>println!("instance.properties.get(i)={other:?}"),
}
//find a function with a matching name
@ -264,14 +264,12 @@ impl mlua::UserData for Instance{
}
})
})?{
return Ok(function.into_lua(lua));
return function.into_lua(lua);
}
//find a child with a matching name
Ok(
find_first_child(dom,instance,index_str)
.map(|instance|Instance::new(instance.referent()))
.into_lua(lua)
)
find_first_child(dom,instance,index_str)
.map(|instance|Instance::new(instance.referent()))
.into_lua(lua)
})
});
methods.add_meta_function(mlua::MetaMethod::NewIndex,|lua,(this,index,value):(Instance,mlua::String,mlua::Value)|{