mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-05 22:09:56 +03:00
Merge pull request #2714 from nippysaurus/patch-1
correct variable reference in setget example
This commit is contained in:
@@ -1202,7 +1202,7 @@ will be called. This happens *before* the value is changed. The *setter* must de
|
||||
with the new value. Vice versa, when ``variable`` is accessed, the *getter* function
|
||||
(``getterfunc`` above) must ``return`` the desired value. Below is an example::
|
||||
|
||||
var myvar setget my_var_set, my_var_get
|
||||
var my_var setget my_var_set, my_var_get
|
||||
|
||||
func my_var_set(new_value):
|
||||
my_var = new_value
|
||||
@@ -1213,9 +1213,9 @@ with the new value. Vice versa, when ``variable`` is accessed, the *getter* func
|
||||
Either of the *setter* or *getter* functions can be omitted::
|
||||
|
||||
# Only a setter.
|
||||
var my_var = 5 setget myvar_set
|
||||
var my_var = 5 setget my_var_set
|
||||
# Only a getter (note the comma).
|
||||
var my_var = 5 setget ,myvar_get
|
||||
var my_var = 5 setget ,my_var_get
|
||||
|
||||
Setters and getters are useful when :ref:`exporting variables <doc_gdscript_exports>`
|
||||
to the editor in tool scripts or plugins, for validating input.
|
||||
|
||||
Reference in New Issue
Block a user