Problem with cloning a node tree


I’m really stumped about this one…

The code:


The output:

DEBUG:SCRIPT: box@(-160, -90, 0)
{ --[[000001423600D660]]
  hash: [] = i@(0, 0, 0)

How is it that, if there very clearly is a node present, its clone is then non-existent?

Strange. How was the node created that you are cloning? Can you share a full example?

Gladly -

if message_id == hash("open_chest") then

		local cloned_tree = gui.clone_tree(gui.get_node("itemContainer_bdummy"))

		self.currentInteractable.nodes = cloned_tree

		gui.set_position(cloned_tree[hash("itemContainer_bdummy")], vmath.vector3(960, 900, 0))

		gui.set_enabled(cloned_tree[hash("itemContainer_bdummy")], true)

		gui.set_enabled(cloned_tree[hash("itemContainerTile_bdummy")], false) =

		self.interactableInUse = true

		local num = 0
		for _,item in pairs(message.contents) do
			num = num + 1"world#item_control", "save_container", { contents = message.contents, name = })


			local proto = self.currentInteractable.nodes[hash("itemContainerTile_bdummy")]
			local cloned_tree = gui.clone_tree(proto)

			gui.set_position(cloned_tree[hash("itemContainerTile_bdummy")], vmath.vector3(-160, -90, 0))
			gui.set_text(cloned_tree[hash("itemContainerTile_tdummy")], string.sub(, 0, 1))

			gui.set_enabled(cloned_tree[hash("itemContainerTile_bdummy")], true)

			table.insert(self.currentInteractable.contents, { id = num, name =, node = cloned_tree[hash("itemContainerTile_bdummy")]})



A lot of this stuff is more or less irrelevant, but I thought I should copy it all, just to be sure.
The code first clones the “itemContainer_bdummy” tree, does some stuff with it, and then, in the for-loop, should clone the “itemContainerTile_bdummy” node from the cloned tree; which is where specifically the gui.clone_tree() function has problems with, and fails to actually clone everything.

The node hierarchy in question:


1 Like

Tried it out by simply taking the prefab tree as the node-to-be-cloned, rather than the one I already cloned and stored in “self.currentInteractable.nodes” - This works.

local cloned_tree = gui.clone_tree(gui.get_node("itemContainerTile_bdummy"))

It’s kind of a workaround as the cloned tree won’t, for example, have the right parent and position, but not a big deal, just requires some correction afterwards.
Still, it’s weird that it doesn’t work with my previous code…

What if you don’t clone the clone so to speak in the for-loop and instead also at that time clone from the original dummy node?

I think you’re describing what I did in my previous reply in the topic? As I said there, it works, and the workaround isn’t a big deal.

I was just like 90% sure when I created the topic that it’s just an error on my part and I’m doing something wrong; but I guess it’s… some kind of bug? Seems like unintended behaviour, at least

You’re right.

Probably. It would be great if you could create a ticket on GitHub!