godot: Could not find base class "_BASE_" when creating script_templates

Godot version

4.1.stable.mono

System information

EndeavourOS (Arch Linux) - Godot v4.1.stable.mono - Vulkan (Mobile) - dedicated NVIDIA GeForce RTX 3070 Ti (nvidia; 535.54.03) - AMD Ryzen 7 5800X 8-Core Processor (16 Threads)

Issue description

Current Situation: Following the doc When trying to create/use script templates, gd language server returns

  Failed parse script res://editor/script_templates/<Node>/default.gd
  Could not find base class "_BASE_"

image

Expected: Godot to parse BASE correctly and register the script template

Steps to reproduce

  • create script_template folder
  • create Node folder
  • create default.gd
  • write a single line:
extends _BASE_

Minimal reproduction project

BaseClassErrorReproduce.zip

Reproduction Project

Additional note:

I dont think the C# version works either, that when i attempt to rewrite the same logic in C# its returning

The type or namespace name '_BINDINGS_NAMESPACE_' could not be found (are you missing a using directive or an assembly reference?)

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 1
  • Comments: 17 (8 by maintainers)

Most upvoted comments

I don’t think there’s any direct checks for the templates like that

See the note (which the addon you reference follows):

The script templates have the same extension as the regular script files. This may lead to an issue of a script parser treating those templates as actual scripts within a project. To avoid this, make sure to ignore the directory containing them by creating an empty .gdignore file. The directory won’t be visible throughout the project’s filesystem anymore, yet the templates can be modified by an external text editor anytime.

The script templates are probably not intended to be edited in the editor

Same with _TS_ tokens. Perhaps, Godot shouldn’t parse files in the res://script_templates/** location. Allow editing templates in the script editor, but don’t parse them at all.

Ah its a different issue - this is specifically for GDScript. The C# part is a side note

I may be missing something but the user seems to be using GDScript. But if the issue is about C#, then it sounds like it would be a duplicate of:

But let me know if I misunderstood the issue.

ah in fact i’ve tested both locations in suspicion that the parser isn’t reading the correct location, but neither is working.

In the original project i’ve relocated the script_templates folder to res://editor/script_templates to test out if things are working or not; and in the minimum reproducible project i’ve kept it under res://script_templates, and tested both importing the addon with concrete implementation & a single line. All scenario failed