+1 vote

I can do a setter and getter and just use has_method("getter"), but is there a more convenient way to just verify if the object has a variable?

in Engine by (1,116 points)

2 Answers

+4 votes
Best answer

You can check this with in keyword. Like for example:

if "varName" in get_parent(): print("varName is defined in parent!")
by (1,297 points)
selected by
0 votes

Check my question here some time ago about the same subject: link

by (429 points)

Weird how you marked the answer that requires you to do the additional step of including a method in your script.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.