Skip to content

Commit

Permalink
Update Gd::with_base method recommendation to Gd::from_init_fn (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lamby777 authored Dec 1, 2023
1 parent ae1842b commit 435a98e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/intro/objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ constructor list.

```admonish note
`init` cannot take custom parameters. There are however a few ways around that.
- From Rust code, simply call [`Gd::with_base()`][gd-with-base].
- From Rust code, simply call [`Gd::from_init_fn()`][gd-from-init-fn].
- From GDScript, you can write a custom method such as `post_init()`, which late-initializes fields. This will reduce type safety though,
needing `Option` for fields whose values aren't available at initialization time.
- Another alternative is to use a third-party class such as `PlayerFactory`, which has a method accepting parameters and returning a
Expand All @@ -122,5 +122,6 @@ Keep in mind that node classes in Godot are manually-managed. When outside the s
using [`free()`][gd-free].


[gd-from-init-fn]: https://godot-rust.github.io/docs/gdext/master/godot/obj/struct.Gd.html#method.from_init_fn
[gd-free]: https://godot-rust.github.io/docs/gdext/master/godot/obj/struct.Gd.html#method.free
[gd]: https://godot-rust.github.io/docs/gdext/master/godot/obj/struct.Gd.html

0 comments on commit 435a98e

Please sign in to comment.