roblox_emulator: implement Instance.Clone
This commit is contained in:
parent
261b88ada6
commit
4ecdcec17c
@ -150,6 +150,15 @@ impl mlua::UserData for Instance{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
fn add_methods<M:mlua::UserDataMethods<Self>>(methods:&mut M){
|
fn add_methods<M:mlua::UserDataMethods<Self>>(methods:&mut M){
|
||||||
|
fn clone(lua:&mlua::Lua,this:&Instance,_:())->mlua::Result<Instance>{
|
||||||
|
dom_mut(lua,|dom|{
|
||||||
|
let instance_ref=dom.clone_within(this.referent);
|
||||||
|
dom.transfer_within(instance_ref,Instance::nil().referent);
|
||||||
|
Ok(Instance::new_unchecked(instance_ref))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
methods.add_method("clone",clone);
|
||||||
|
methods.add_method("Clone",clone);
|
||||||
fn get_children(lua:&mlua::Lua,this:&Instance,_:())->mlua::Result<Vec<Instance>>{
|
fn get_children(lua:&mlua::Lua,this:&Instance,_:())->mlua::Result<Vec<Instance>>{
|
||||||
dom_mut(lua,|dom|{
|
dom_mut(lua,|dom|{
|
||||||
let instance=this.get(dom)?;
|
let instance=this.get(dom)?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user