0 votes

In the previous version I used this:

if foo is get_script():
      etc.

to check if an object was another instance of the script.
Now it gives an error: "right operand is not a type (not a native type nor a script)".

in Engine by (60 points)

1 Answer

+1 vote
Best answer

Hey zubzob,
In godot3.1 you can use the class
name keyword for this. If you set up your script like this:

extends whatever

class_name MySpecialNode

...

Then you can use:

var node = get_node("lalala")
if node is MySpecialNode:
   print("lol it works")

Hope it works :) Good luck!

by (864 points)
selected by
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.