Skip to content

Clarify rules around which scripts require @tool in Running code in the editor #10888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Apr 22, 2025

  • Mention that static methods work, but not static variables.
  • Emphasize the use of version control due to the lack of undo/redo.

@Calinou Calinou added enhancement area:manual Issues and PRs related to the Manual/Tutorials section of the documentation cherrypick:4.4 cherrypick:4.3 labels Apr 22, 2025
… the editor

- Mention that static methods work, but not static variables.
- Emphasize the use of version control due to the lack of undo/redo.
@Calinou Calinou force-pushed the running-code-in-the-editor-static-context branch from 3ad2eaa to ab7c43c Compare April 22, 2025 12:47
files without ``@tool``, which means you cannot call methods or reference member
variables from them otherwise. However, since static methods, constants and
enums can be used without creating an instance, it is possible to call them or
reference them from a ``@tool`` script onto other non-tool scripts. One exception to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is onto instead of on here what is commonly used in the docs?

Copy link
Member

@dalexeev dalexeev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

this are :ref:`static variables <doc_gdscript_basics_static_variables>`.
If you try to read a static variable's value in a script that does not have
``@tool``, it will always return ``null`` but won't print a warning or error
when doing so. This restriction does not apply to static methods, which can be
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that static functions can access static variables. Although this is stated above, this exception can be a bit confusing. Is there any way we can clarify this without making the documentation even more complicated? Maybe like this:

Suggested change
when doing so. This restriction does not apply to static methods, which can be
when doing so. This restriction does not apply to pure static methods, which can be

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:manual Issues and PRs related to the Manual/Tutorials section of the documentation cherrypick:4.3 cherrypick:4.4 enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants