Some time ago we came across a funny fact: gui.clone_tree() don’t work if source node already cloned.
Perhaps this is done on purpose. I would like to clarify this situation for the future.
1 Like
What happens when you try to copy already cloned nodes? Some error or something else?
We got a table with some other nodes as a result. Not the one that cloned. It was like thrash.
This sure sounds like a bug. I’m not in front of a computer right now. Perhaps someone else can verify? @sven
I have a old prototype, where i use gui.clone_tree().
Looks like it working. I use it in init function. Not sure that all will work in update function.
function M.copy_nodes(node,lenght)
local cards_nodes={}
for i = 1,lenght do
local card_node=gui.clone_tree(node)
cards_nodes[i]=card_node
end
return cards_nodes
end
in gui
local function create_nodes()
local card_node = gui.get_node("card_template/background")
cards_nodes = card_helper.copy_nodes(card_node, deck.width * deck.height)
card_helper.set_nodes_positions(cards_nodes,deck,screen,paddings)
gui.delete_node(card_node)
end
1 Like
Yes, there is problem with cloning of clone made with clone_tree.
You can see the cloned nodes but you can do nothing with them. Returned table has only 1 node.
1 Like