diff --git a/src/faq/code.md b/src/faq/code.md index 09f19ff..46b7c89 100644 --- a/src/faq/code.md +++ b/src/faq/code.md @@ -1,5 +1,20 @@ # FAQ: Common code questions +## Table of contents + +- [What is the `BorrowFailed` error and why do I keep getting it?](#what-is-the-borrowfailed-error-and-why-do-i-keep-getting-it) +- [Why are methods on all Godot API classes using `&self` even when they should cause mutations?](#why-are-methods-on-all-godot-api-classes-using-self-even-when-they-should-cause-mutations) +- [Why is there so much `unsafe` in godot-rust?](#why-is-there-so-much-unsafe-in-godot-rust) +- [As a native script type needs to implement `fn new(owner: &Node) -> Self`, is it possible to pass additional arguments to `new`?](#as-a-native-script-type-needs-to-implement-fn-new(owner:-&node)-->-self-is-it-possible-to-pass-additional-arguments-to-new) +- [How can I implement static methods in GDNative?](#how-can-i-implement-static-methods-in-gdnative) +- [How to I convert from a `Variant` or other Godot Type to the underlying Rust type?](#how-to-i-convert-from-a-variant-or-other-godot-type-to-the-underlying-rust-type) +- [Is it possible to set subproperties of a Godot type, such as a Material?](#is-it-possible-to-set-subproperties-of-a-godot-type-such-as-a-material) +- [What is the godot-rust equivalent of `preload`?](#what-is-the-godot-rust-equivalent-of-preload) +- [How do I keep a reference of `Node`?](#how-do-i-keep-a-reference-of-node) +- [What is the Rust equivalent to `onready var` in GDScript](#what-is-the-rust-equivalent-to-onready-var-in-gdscript) +- [What types are supported for passing through the GDNative API?](#what-types-are-supported-for-passing-through-the-gdnative-api) +- [How can I profile my code to determine the performance?](#how-can-i-profile-my-code-to-determine-the-performance) + ## What is the `BorrowFailed` error and why do I keep getting it? In Rust, [there can only be *one* `&mut` reference to the same memory location at the same time](https://docs.rs/dtolnay/0.0.9/dtolnay/macro._02__reference_types.html). To enforce this while making simple use cases easier, the bindings make use of [interior mutability](https://doc.rust-lang.org/book/ch15-05-interior-mutability.html). This works like a lock: whenever a method with `&mut self` is called, it will try to obtain a lock on the `self` value, and hold it *until it returns*. As a result, if another method that takes `&mut self` is called in the meantime for whatever reason (e.g. signals), the lock will fail and an error (`BorrowFailed`) will be produced. diff --git a/src/faq/community.md b/src/faq/community.md index 291111c..a76140d 100644 --- a/src/faq/community.md +++ b/src/faq/community.md @@ -1,5 +1,9 @@ # FAQ: Community +## Table of contents + +- [I need help, where can I ask?](#i-need-help-where-can-i-ask) + ## I need help, where can I ask? The godot-rust project uses several different sources for different kinds of information. diff --git a/src/faq/configuration.md b/src/faq/configuration.md index c3b0fd3..9450d54 100644 --- a/src/faq/configuration.md +++ b/src/faq/configuration.md @@ -1,5 +1,17 @@ # FAQ: Configuration +## Table of contents + +- [How do I create the library file for my GDNative binary?](#how-do-i-create-the-library-file-for-my-gdnative-binary) +- [Once I create the `.gdnlib` file, how do I create the native script, so that I can attach it to the nodes in the scene tree?](#once-i-create-the-gdnlib-file-how-do-i-create-the-native-script-so-that-i-can-attach-it-to-the-nodes-in-the-scene-tree) +- [Why aren't my scripts showing up in the _Add Node_ portion of the editor, even though they inherit from `Node`, `Node2D`, `Spatial` or `Control`?](#why-arent-my-scripts-showing-up-in-the-add-node-portion-of-the-editor-even-though-they-inherit-from--node-node2d-spatial-or-control) +- [Can I use Rust for a tool script?](#can-i-use-rust-for-a-a-hrefhttpsdocsgodotengineorgenstabletutorialsmiscrunning_code_in_the_editorhtmltool-scripta) +- [Is it possible to use multiple libraries with GDNative?](#is-it-possible-to-use-multiple-libraries-with-gdnative) +- [Can I expose {insert Rust crate name} for use with Godot and GDScript?](#can-i-expose-insert-rust-crate-name-for-use-with-godot-and-gdscript) +- [How do I get auto-completion with rust-analyzer?](#how-do-i-get-auto-completion-with-rust-analyzer) +- [How do I get auto-completion with IntelliJ-Rust plugin?](#how-do-i-get-auto-completion-with-intellij-rust-plugin) +- [How can I make my debug builds more performant?](#how-can-i-make-my-debug-builds-more-performant) + ## How do I create the library file for my GDNative binary? You can create .gdnlib files with either of the following methods. diff --git a/src/faq/godot4.md b/src/faq/godot4.md index 78969fc..600485c 100644 --- a/src/faq/godot4.md +++ b/src/faq/godot4.md @@ -1,5 +1,13 @@ # FAQ: Godot 4.0 Status +## Table of contents + +- [What is the status of Godot 4 Support?](#what-is-the-status-of-godot-4-support) +- [So what is the plan?](#so-what-is-the-plan) +- [What is GDExtension? Why aren't we just upgrading GDNative?](#what-is-gdextension-why-arent-we-just-upgrading-gdnative) +- [What do we know so far?](#what-do-we-know-so-far) +- [How can I help?](#how-can-i-help) + ## What is the status of Godot 4 Support? Currently we are still in the planning phase of determining how to support Godot 4.0 and where we will focus our efforts in the future. diff --git a/src/faq/multithreading.md b/src/faq/multithreading.md index 9bd4b18..f67d2dd 100644 --- a/src/faq/multithreading.md +++ b/src/faq/multithreading.md @@ -1,5 +1,12 @@ # FAQ: Multithreading +## Table of contents + +- [How do I use multithreading?](#how-do-i-use-multithreading) +- [Why does my game freeze while using multiple threads?](#why-does-my-game-freeze-while-using-multiple-threads) +- [Why is accessing the servers using multiple threads is slow?](#why-is-accessing-the-servers-using-multiple-threads-is-slow) +- [Why do I get `DifferentThread` error when calling my code from multiple threads?](#why-do-i-get-differentthread-error-when-calling-my-code-from-multiple-threads) + ## How do I use multithreading? Follow [Godot's thread safety guidelines](https://docs.godotengine.org/en/stable/tutorials/threads/index.html) and change your settings to "Multi-threaded" in "Project Settings > Rendering > Threading". diff --git a/src/faq/support.md b/src/faq/support.md index 1b91a4b..a461b65 100644 --- a/src/faq/support.md +++ b/src/faq/support.md @@ -1,5 +1,15 @@ # FAQ: Versioning and supported platforms +## Table of contents + +- [What does godot-rust's version mean?](#what-does-godot-rusts-version-mean) +- [Is godot-rust stable?](#is-godot-rust-stable) +- [Will godot-rust support Godot 4.0?](#will-godot-rust-support-godot-40) +- [What is the scope of the godot-rust project?](#what-is-the-scope-of-the-godot-rust-project) +- [Will godot-rust speed up my game in Godot?](#will-godot-rust-speed-up-my-game-in-godot) +- [Which platforms are supported?](#which-platforms-are-supported) +- [Does godot-rust support consoles?](#does-godot-rust-support-consoles) + ## What does godot-rust's version mean? godot-rust follows [Cargo's semantic versioning](https://doc.rust-lang.org/cargo/reference/semver.html) for the API breaking changes.