default properties

This commit is contained in:
Quaternions 2024-10-05 13:10:57 -07:00
parent 4988eeed65
commit a9a4ed2c46

View File

@ -251,10 +251,18 @@ impl Instance{
let dereferent:Dereferent=mlua::AnyUserDataExt::get(&this,"Referent")?; let dereferent:Dereferent=mlua::AnyUserDataExt::get(&this,"Referent")?;
dom_mut(lua,|dom|{ dom_mut(lua,|dom|{
let instance=dereferent.get(dom)?; let instance=dereferent.get(dom)?;
match instance.properties.get(index_str){ //Find existing property
match instance.properties.get(index_str)
//Find default value
.or_else(||{
let db=rbx_reflection_database::get();
db.classes.get(instance.class.as_str()).and_then(|cd|
db.find_default_property(cd,index_str)
)
})
{
Some(&rbx_types::Variant::CFrame(cf))=>return Ok(Into::<super::cframe::CFrame>::into(cf).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::Vector3(v))=>return Ok(Into::<super::vector3::Vector3>::into(v).into_lua(lua)),
//None=>get_default_value
_=>(), _=>(),
} }
//find a child with a matching name //find a child with a matching name