From ff76f3c865cdc55dccc5ad9439f160ea6d712a4d Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 20 Sep 2024 18:01:33 -0700 Subject: [PATCH] Instance: name --- src/runner/instance.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/runner/instance.rs b/src/runner/instance.rs index 551c6ff..09bc459 100644 --- a/src/runner/instance.rs +++ b/src/runner/instance.rs @@ -52,6 +52,20 @@ impl mlua::UserData for Instance{ Ok(()) }) }); + fields.add_field_method_get("Name",|lua,this|{ + dom(lua,|dom|{ + let instance=this.get(dom)?; + Ok(instance.name.clone()) + }) + }); + fields.add_field_method_set("Name",|lua,this,val:String|{ + dom(lua,move|dom|{ + let instance=this.get_mut(dom)?; + //Why does this need to be cloned? + instance.name=val.clone(); + Ok(()) + }) + }); } fn add_methods<'lua,M:mlua::UserDataMethods<'lua,Self>>(methods:&mut M){