From acbb1c8478a0f40e845dfd12aab05e6be996eb66 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 4 Oct 2024 19:05:05 -0700 Subject: [PATCH] workspace.Terrain --- src/runner/instance.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/runner/instance.rs b/src/runner/instance.rs index 792010c..5a229b0 100644 --- a/src/runner/instance.rs +++ b/src/runner/instance.rs @@ -333,8 +333,20 @@ impl DataModel{ } class!(Workspace); -class_composition!(Workspace,(Instance)); - +class_composition!(Workspace,(Instance,Workspace)); +impl Workspace{ + fn composition_add_fields<'lua,T:Referent,F:mlua::UserDataFields<'lua,T>>(fields:&mut F){ + fields.add_field_method_get("Terrain",|lua,this|{ + dom(lua,|dom|{ + Ok(find_first_child_of_class(dom,this.get(dom)?,"Terrain") + .map(|inst|Terrain::new(inst.referent())) + ) + }) + }); + } + fn composition_add_methods<'lua,T,M:mlua::UserDataMethods<'lua,T>>(_methods:&mut M){ + } +} class!(Lighting); class_composition!(Lighting,(Instance));