local function node_to_key(node)
local url = msg.url()
return hash_to_hex(url.socket) .. hash_to_hex(url.path) .. hash_to_hex(url.fragment) .. hash_to_hex(gui.get_id(node))
end
function init(self)
self.clone = gui.get_node("clone")
for i=1, 10 do
local c = gui.clone(self.clone)
print(node_to_key(c))
end
end
You could manually generate and set an id using gui.set_id() to fix this. I did however add code to assign an auto-generated id to button nodes that have no id (empty hash).
Registering buttons created from nodes overwrite each other.
hash_to_hex(gui.get_id(node))
is identical for clones.https://github.com/britzl/defold-input/blob/a9cceb9c96d3fe25aacfba3bba975d02b0632b74/in/button.lua#L38