GUI: node used in the wrong scene

What this error means?

It shows, when I call gui.get_parent. I am using Monarch to show a dialog popup. When I get back to the previous screen and try to enter the same dialog again it loads, using monarch.show(hash("dialog"), {reload = true}, nil, function() end) but first call of gui.get_parent fails with the error above :confused:

This means that you are somehow referencing a gui node that doesn’t belong to the gui scene your script belongs to. Can you create a GitHub issue and share a repro case?

Sorry, I didn’t ever answered back to this, but today I came on the same issue and I found the reason for this and it does not have anything to do with Monarch (as Monarch was just to switch GUI scenes):

I was storing gui.get_node() results as local variables in Lua module. After switching scene, I should have reassign new gui.get_node() results to those proper variables, which I didn’t do, so the code reused from the same module was operating on old ids :frowning:

So simply in such cases - use actual id in GUI scripts (or refresh ids, if you store them in variables, after switching to a new GUI) and yeah, the error is meaning exactly what it is :wink:

1 Like

@Pawel Refresh Ids ? What is I can mean it? or How or What is the way to refresh ids?

By refreshing ids - I meant exactly this. I stored in local variables in a separate Lua module the ids of the GUI I was handling previously and after switching to other GUI I should refresh/reassign them.

2 Likes

@Pawel I discovered this error when I save to a local variable with a node and after deleting the old gui, the factory creates a new gui, with functions that use those nodes that will generate this error even though I reassigned the new node to the other local variables

1 Like