Skip to content
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

GDScript "Parse Error: Script export type must be a global class." regression in HungryProton Scatter plugin #93168

Closed
akien-mga opened this issue Jun 14, 2024 · 3 comments · Fixed by #93384

Comments

@akien-mga
Copy link
Member

Tested versions

System information

Fedora Linux 40 (KDE Plasma) - Wayland - Vulkan (Forward+) - dedicated AMD Radeon RX 7600M XT (RADV NAVI33) - AMD Ryzen 7 7840HS w/ Radeon 780M Graphics (16 Threads)

Issue description

When opening a project using the https://github.com/HungryProton/scatter addon (installed from the asset lib), the following errors are printed:

SCRIPT ERROR: Parse Error: Script export type must be a global class.
          at: GDScript::reload (res://addons/proton_scatter/src/stack/modifier_stack.gd:15)
SCRIPT ERROR: Compile Error: 
          at: GDScript::reload (res://addons/proton_scatter/src/scatter.gd:-1)
SCRIPT ERROR: Parse Error: Script export type must be a global class.
          at: GDScript::reload (res://addons/proton_scatter/src/stack/modifier_stack.gd:15)
SCRIPT ERROR: Compile Error: 
          at: GDScript::reload (res://addons/proton_scatter/src/common/scatter_util.gd:-1)
SCRIPT ERROR: Compile Error: 
          at: GDScript::reload (res://addons/proton_scatter/src/scatter_shape.gd:-1)
SCRIPT ERROR: Compile Error: 
          at: GDScript::reload (res://addons/proton_scatter/src/shapes/gizmos_plugin/components/path_panel.gd:-1)
ERROR: Failed to load script "res://addons/proton_scatter/src/shapes/gizmos_plugin/components/path_panel.gd" with error "Compilation failed".
   at: load (./modules/gdscript/gdscript.cpp:2943)
SCRIPT ERROR: Invalid call. Nonexistent function 'selection_changed' in base 'MarginContainer (path_panel.gd)'.
          at: _on_selection_changed (res://addons/proton_scatter/plugin.gd:137)

This is a recent regression which doesn't appear in 4.3-beta1.

Steps to reproduce

  • Create new project
  • Install and enabled HungryProton scatter addon

Minimal reproduction project (MRP)

testscatter.zip

@akien-mga akien-mga added this to the 4.3 milestone Jun 14, 2024
@akien-mga akien-mga moved this from Unassessed to Release Blocker in 4.x Release Blockers Jun 14, 2024
@akien-mga akien-mga moved this from Release Blocker to Immediate Blocker in 4.x Release Blockers Jun 14, 2024
@dalexeev
Copy link
Member

dalexeev commented Jun 14, 2024

This is intentional, the inspector only supports global classes. Previously in GDScript there was an inconsistency between SCRIPT and CLASS datatypes.

Also, it's documented:

Note: Custom resources and nodes must be registered as global classes using class_name.

Alternatively, we could use a native class instead, if the script is not a global class.

@akien-mga
Copy link
Member Author

akien-mga commented Jun 17, 2024

I confirm that the following change fixes the issue for the Scatter plugin:

diff --git a/addons/proton_scatter/src/modifiers/base_modifier.gd b/addons/proton_scatter/src/modifiers/base_modifier.gd
index 244d465..3c30edb 100644
--- a/addons/proton_scatter/src/modifiers/base_modifier.gd
+++ b/addons/proton_scatter/src/modifiers/base_modifier.gd
@@ -1,4 +1,5 @@
 @tool
+class_name BaseModifier
 extends Resource
 
 # Modifiers place transforms. They create, edit or remove transforms in a list,
diff --git a/addons/proton_scatter/src/stack/modifier_stack.gd b/addons/proton_scatter/src/stack/modifier_stack.gd
index 3b46123..65c2afe 100644
--- a/addons/proton_scatter/src/stack/modifier_stack.gd
+++ b/addons/proton_scatter/src/stack/modifier_stack.gd
@@ -9,7 +9,6 @@ signal transforms_ready
 
 const ProtonScatter := preload("../scatter.gd")
 const TransformList := preload("../common/transform_list.gd")
-const BaseModifier := preload("../modifiers/base_modifier.gd")
 
 
 @export var stack: Array[BaseModifier] = []

There main problem I see is that plugins tend to avoid using class_name to avoid polluting the game's namespace with plugin-internal classes. I suppose this is why @HungryProton used preloads for these instead of class_name.

I suspect we'll find more addons with similar broken compatibility with 4.3 after this change. I'm not sure telling all the plugin authors to use class_name instead will be a satisfactory option for all.

For example @shakesoda already mentioned that the Spatial Gardener plugin seems to have the same issue.

@HungryProton
Copy link
Contributor

HungryProton commented Jun 20, 2024

If there were a way to tell Godot that a class is not meant to be exposed to the end user, I'd be more than happy to use global class names everywhere.

I avoid class_names for nodes because I don't want them to show up in the Create new node window unless the plugin is actually enabled (otherwise these nodes don't work properly).

This one is an exported resource so I guess I can make the fix on my end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Very Bad
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants