Godot Version
Godot 4.2.1
Question
I’m working on something that relies heavily on composition (I’ve tried inheritance, and I don’t like it), and I need to know if a node has variable ( I’m not going to post the tree, as this method should work for any node, regardless of tree position). I’ve come up with a solution to this myself, as Godot seems to have no built-in method for this, but I don’t know if it’s the best way.
static func has_property(argument:String,node:Node)->bool:
var script=node.get_script()
var propertylistarray=script.get_script_property_list()
for propertydic in propertylistarray:
var propertyname:String=propertydic.get("name")
if not propertyname.ends_with(".gd"):
if propertyname==argument:
return true
else:
return false
return false
