Skip to content

Commit 2c66120

Browse files
authored
Adding more detail on how to use export variables.
Making it easier for people to understand how export variables work, I found out about this while looking at the issues, and this should be easier to find.
1 parent 2da9364 commit 2c66120

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,32 @@ export default class MySprite extends godot.Sprite {
7070
godot.register_property(MySprite, 'direction', new godot.Vector2(1, 0));
7171
```
7272

73+
There are 2 ways of using the `godot.register_property`, the thrid param can either be
74+
a default value for the property you're trying to export or an object giving a more detailed
75+
description on how the editor should show it.
76+
77+
```js
78+
function register_property(target: GodotClass | godot.Object, name: string, value: any);
79+
function register_property(target: GodotClass | godot.Object, name: string, info: PropertyInfo);
80+
```
81+
82+
So calling the register_property like this:
83+
```js
84+
godot.register_property(MyClass, 'number_value', 3.14);
85+
```
86+
87+
Is the simplified version of:
88+
```js
89+
godot.register_property(MyClass, 'number_value', {
90+
type: godot.TYPE_REAL,
91+
hint: godot.PropertyHint.PROPERTY_HINT_NONE,
92+
hint_string: "",
93+
default: 3.14
94+
});
95+
```
96+
97+
For more detail on how to use it, [click here](https://github.com/GodotExplorer/ECMAScript/issues/24#issuecomment-655584829).
98+
7399
#### About the API
74100

75101
All of godots api's are defined within the `godot` namespace.

0 commit comments

Comments
 (0)