From 6efa811eb6488b23f8d59958952e5f301d06ce77 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 22 Sep 2023 14:21:22 -0700 Subject: [PATCH] generalize recursive_collect --- src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index acf0bad..04c9529 100644 --- a/src/main.rs +++ b/src/main.rs @@ -48,13 +48,13 @@ fn class_is_a(class: &str, superclass: &str) -> bool { } return false } -fn recursive_collect_scripts(scripts: &mut std::vec::Vec,dom: &rbx_dom_weak::WeakDom, instance: &rbx_dom_weak::Instance){ +fn recursive_collect_superclass(objects: &mut std::vec::Vec,dom: &rbx_dom_weak::WeakDom, instance: &rbx_dom_weak::Instance, superclass: &str){ for &referent in instance.children() { if let Some(c) = dom.get_by_ref(referent) { - if class_is_a(c.class.as_str(), "LuaSourceContainer") { - scripts.push(c.referent());//copy ref + if class_is_a(c.class.as_str(), superclass) { + objects.push(c.referent());//copy ref } - recursive_collect_scripts(scripts,dom,c); + recursive_collect_superclass(objects,dom,c,superclass); } } } @@ -89,7 +89,7 @@ fn get_full_name(dom:&rbx_dom_weak::WeakDom,instance:&rbx_dom_weak::Instance) -> fn get_script_refs(dom:&rbx_dom_weak::WeakDom) -> Vec{ let mut scripts = std::vec::Vec::new(); - recursive_collect_scripts(&mut scripts, dom, dom.root()); + recursive_collect_superclass(&mut scripts, dom, dom.root(),"LuaSourceContainer"); scripts }