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_text(cloned_tree[hash("itemContainer_tdummy")], message.name)
gui.set_enabled(cloned_tree[hash("itemContainer_bdummy")], true)
gui.set_enabled(cloned_tree[hash("itemContainerTile_bdummy")], false)
self.currentInteractable.name = message.name
self.interactableInUse = true
local num = 0
for _,item in pairs(message.contents) do
num = num + 1
msg.post("world#item_control", "save_container", { contents = message.contents, name = message.name })
pprint(self.currentInteractable.nodes[hash("itemContainerTile_bdummy")])
pprint(gui.clone_tree(self.currentInteractable.nodes[hash("itemContainerTile_bdummy")]))
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(item.name, 0, 1))
gui.set_enabled(cloned_tree[hash("itemContainerTile_bdummy")], true)
table.insert(self.currentInteractable.contents, { id = num, name = item.name, node = cloned_tree[hash("itemContainerTile_bdummy")]})
end
end
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.
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…
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