None maps to Nil ezpz
This commit is contained in:
parent
acbb1c8478
commit
ba9918f2d5
@ -171,16 +171,17 @@ impl Instance{
|
||||
};
|
||||
dom(lua,|dom|{
|
||||
let instance=this.get(dom)?;
|
||||
let child=match search_descendants{
|
||||
Ok(
|
||||
match search_descendants{
|
||||
true=>dom.descendants_of(this.referent()).find(|inst|inst.name==name_str),
|
||||
false=>instance.children().iter().filter_map(|&r|
|
||||
dom.get_by_ref(r)
|
||||
).find(|inst|inst.name==name_str),
|
||||
};
|
||||
match child{
|
||||
Some(instance)=>Instance::new(instance.referent()).into_lua(lua),
|
||||
None=>mlua::Value::Nil.into_lua(lua),
|
||||
}
|
||||
.map(|instance|
|
||||
Instance::new(instance.referent())
|
||||
)
|
||||
)
|
||||
})
|
||||
};
|
||||
methods.add_method("FindFirstChild",ffc);
|
||||
@ -224,16 +225,15 @@ impl Instance{
|
||||
dom(lua,|dom|{
|
||||
let instance=dereferent.get(dom)?;
|
||||
//find a child with a matching name
|
||||
let maybe_child=instance.children()
|
||||
Ok(
|
||||
instance.children()
|
||||
.iter()
|
||||
.find(|&&r|
|
||||
dom.get_by_ref(r)
|
||||
.is_some_and(|instance|instance.name==index_str)
|
||||
);
|
||||
match maybe_child{
|
||||
Some(&referent)=>Instance::new(referent).into_lua(lua),
|
||||
None=>mlua::Value::Nil.into_lua(lua),
|
||||
}
|
||||
)
|
||||
.map(|&referent|Instance::new(referent))
|
||||
)
|
||||
})
|
||||
});
|
||||
methods.add_meta_function(mlua::MetaMethod::NewIndex,|lua,(this,index,value):(mlua::AnyUserData,mlua::String,mlua::Value)|{
|
||||
|
Loading…
Reference in New Issue
Block a user