Properties Vs Functions

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Koroshiya

Some nodes can be used by properties or functions, to apparently perform the same effect. For example:

 get_node("Button1").disabled = true

Why ?
What is the difference?
One is better than the other?

:bust_in_silhouette: Reply From: clemens.tolboom

Have a function gives you more control over what will happen when setting a value.

Your Button has BaseButton implementing disabled BaseButton

Setting disabled = false will call set_disabled(false) under the hood.

A more complex example is ie See ie is_active

var is_active = true setget set_is_active

when settings is_active = true will call set_is_active(true) under the hood.

func set_is_active(value):
    is_active = value
    set_block_signals(not value)

which is a complex action.