Issues with setting object meta data.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By avencherus
:warning: Old Version Published before Godot 3 was released.

I encountered a strange problem involving setting metadata that I can’t find any cause for. Was wondering if anyone had any suggestions on what to check.

If a parent node at initialization I call set_meta(“data”, 1). I check it with get_meta, and it is there.

However in the children nodes, they can’t see to see the meta data. I get_parent(), it is the correct node, but it has none of it’s meta data. Even when deferring and looping, it never shows up.

So the parent will report having, the children can’t find it.

In another scene I made weeks ago using this method, it is identical code, and actually works just fine…

I’m starting to suspect some sort of internal bug. Anyone have anything to add?

Thanks. :slight_smile:

I did a quick test with Controls and get_parent().get_meta() works fine, metadata was added by parent on ready, got the metadata with a button.

Are you adding metadata on init, after init, on ready?

eons | 2017-01-19 01:19

It’s being added on init(). I one scene it works fine. In another the same set up does not. The output reports that the meta data is there in any code attached to the parent. However, none of the children, regardless of timing can find that meta data.

They are referencing the same constants. It is rather strange.

At the moment I’ve just changed everything to using member variables instead, with some special logic to test if the variable exists. I can’t replicate it in any normal nodes or conditions. It seems to be happening in my custom plugin nodes, so maybe there is some issue there.

If you can be bothered, maybe check for me if a set of separate plugin custom nodes fail this on your end as well.

CustomA (init → set meta) child CustomB (get_parent().get_meta())

avencherus | 2017-01-19 01:27

Plugins hate me but will try ^_^;

eons | 2017-01-19 01:41

Thanks. Hopefully it’s a quirk of custom nodes.

avencherus | 2017-01-19 01:48

Tried with 2 custom nodes that found on a messy testbed project and works.

What I did is set_meta on init of the parent, then get_parent().get_meta on a function of the child, it works even when called on _ready.


Just realized I have no idea of how to instance custom nodes by code o_O

eons | 2017-01-19 02:15

Hmmm, I guess I don’t know then. Maybe something deeper was conflicting, I am using quite a bit of tool code, and sometimes the errors don’t really manifest where you would expect. Everything runs fine though now that I’ve replaced all the meta data calls with variables.

As far as instancing custom nodes, I think it’s just editor eye candy the way they’re presented. Instancing a node at runtime would be just creating the node and adding the script to it before adding it to the scene.

I imagine that’s all it does in the editor, but registering it via the plugin class gives it an icon and allows you to quickly create them from the node menu.

avencherus | 2017-01-19 02:21

Try setting meta on ready, to see what happens and reduce the scope of the problem.

And using ready should be the same as init because custom nodes are always ready.

eons | 2017-01-19 02:49

I believe the issue was in some hidden tool mode issue. I’ve fixed certain other seemingly unrelated issues, and the problem has vanished.

It works fine as init and in ready again. I suspect something in the tool code were causing issues with how these nodes were entering the scene tree behind the scenes and not exactly reporting them.

avencherus | 2017-01-19 02:57