setgetwhen defining variables that are outside functions. The syntax is as follows.
var setter_and_getter setget setter, getter
var only_setter setget setter
var only_getter setget , getter
# Any initialization of a variable most be done before setget.
var setget_initialized = 0 setget setter, getter
getter are functions that you must define in the script. The simplest example of these two are as follows.
something = value
The setter function is called whenever it's corresponding variable gets set.
And the getter is called when said variable is accessed in anyway.
#assuming something is from a different script
something = 0 # setter gets called.
var other = something # getter gets called.
They won't be called however if the variable being manipulated is inside the same script it was defined.
#assuming something is in the same script
something = 0 # setter does not get called.
self.something = 0 # doing this will make the setter get called.