GUI, how to delete only cloned tree_nodes and not the one that gets cloned

Hi,

In my GUI I create clones from the Node tree of a template I have.

In the Init function I have a function called draw() which handles the creation of the GUI at runtime. I save these cloned node trees in a table.

After the user buys upgrades for the game in this GUI I want to redraw the cloned node_trees to reflect the changes. So my approach would be to delete the cloned node_trees and then call the draw() function again.

The problem is if i delete the ID of one of the cloned node_trees it deletes all of them, even the one i use to create the clones from. When i check the table of the cloned_trees they all have the same hash ids.

Questions:

  1. Is my approach to relaod these created node trees correct by deleting and redrawing them.
  2. Do the cloned node_trees not have their own ID so i can adress them?
  3. Another approach would be cloned the nodes_tree in gui save it in a table and draw it on update? this may be the way to go or what would be best practice?

The returned table from gui.clone_tree() contains a mapping from the old id to the new.
That is, they all have new ids, and to find it, use the old id as a key n the lookup table.

Ok thank you.
For my approach i did create a cloned node_tree in the init function for each ability to show as GUI node and saved it in a table.
In the update i draw these cloned node_trees and position them correctly. This way the values are always up to date with changes (upgrades of abilties).
Would that be the correct approach?

Yes, that sounds right.

I’m not sure what you mean by “I draw these” because the engine is drawing them for you. Do you mean that you enable them/make them visible?

Yes exactly that is what i mean and it works great. Thanks for the clarifaction and letting me know i do the right approach.

1 Like