Skip to content

Commit aab5dc7

Browse files
AThousandShipsmhilbrunnerakien-mga
authored
Fix method bind instructions and style (godotengine#8735)
* Fix method bind instructions and style --------- Co-authored-by: Max Hilbrunner <[email protected]> Co-authored-by: Rémi Verschelde <[email protected]>
1 parent 1639413 commit aab5dc7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

contributing/development/core_and_modules/object_class.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,17 @@ Registering functions is one:
7171

7272
.. code-block:: cpp
7373
74-
ClassDB::bind_method(D_METHOD("methodname", "arg1name", "arg2name"), &MyCustomMethod);
74+
ClassDB::bind_method(D_METHOD("methodname", "arg1name", "arg2name", "arg3name"), &MyCustomType::method);
7575
76-
Default values for arguments can be passed in reverse order:
76+
Default values for arguments can be passed as parameters at the end:
7777

7878
.. code-block:: cpp
7979
80-
ClassDB::bind_method(D_METHOD("methodname", "arg1name", "arg2name"), &MyCustomType::method, DEFVAL(-1)); // default value for arg2name
80+
ClassDB::bind_method(D_METHOD("methodname", "arg1name", "arg2name", "arg3name"), &MyCustomType::method, DEFVAL(-1), DEFVAL(-2)); // Default values for arg2name (-1) and arg3name (-2).
81+
82+
Default values must be provided in the same order as they are declared,
83+
skipping required arguments and then providing default values for the optional ones.
84+
This matches the syntax for declaring methods in C++.
8185

8286
``D_METHOD`` is a macro that converts "methodname" to a StringName for more
8387
efficiency. Argument names are used for introspection, but when
@@ -142,7 +146,7 @@ For example:
142146
143147
PropertyInfo(Variant::INT, "amount", PROPERTY_HINT_RANGE, "0,49,1", PROPERTY_USAGE_EDITOR)
144148
145-
This is an integer property named "amount". The hint is a range, and the range
149+
This is an integer property named "amount". The hint is a range, and the range
146150
goes from 0 to 49 in steps of 1 (integers). It is only usable for the editor
147151
(editing the value visually) but won't be serialized.
148152

0 commit comments

Comments
 (0)