This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function build_hierarchy(root) | |
local node_and_descendants = {} | |
local node_info = {} | |
local all_nodes = gui.get_tree(gui.get_node(root)) | |
-- Build an array of (node + its descendants) for each node | |
for node_id,_ in pairs(all_nodes) do | |
local nodes | |
if node_id == root then | |
nodes = all_nodes -- avoid calling get_tree again for the root node |