RodZill4 / material-maker

A procedural textures authoring and 3D model painting tool based on the Godot game engine
MIT License
3.55k stars 224 forks source link

Can't enable plugin when downloaded from AssetLib #139

Open Vivraan opened 4 years ago

Vivraan commented 4 years ago

Material Maker version: .92

OS/device including version: Windows 10, Godot v3.2.2 Mono Stable

Issue description: When I tried to import the plugin, I immediately got a bunch of errors, preventing me from using it.

 res://addons/material_maker/engine/gen_base.gd:222 - Parse Error: The identifier "mm_io_types" isn't declared in the current scope.
 modules/gdscript/gdscript.cpp:599 - Method failed. Returning: ERR_PARSE_ERROR
 res://addons/material_maker/engine/gen_shader.gd:105 - Parse Error: The identifier "OutputPort" isn't a valid type (not a script or class), or couldn't be found on base "self".
 modules/gdscript/gdscript.cpp:599 - Method failed. Returning: ERR_PARSE_ERROR
 res://addons/material_maker/engine/gen_material.gd:52 - Parse Error: The method "add_to_group" isn't declared in the current class.
 modules/gdscript/gdscript.cpp:599 - Method failed. Returning: ERR_PARSE_ERROR
 res://addons/material_maker/engine/gen_base.gd:222 - Parse Error: The identifier "mm_io_types" isn't declared in the current scope.
 modules/gdscript/gdscript.cpp:599 - Method failed. Returning: ERR_PARSE_ERROR
 res://addons/material_maker/engine/gen_shader.gd:105 - Parse Error: The identifier "OutputPort" isn't a valid type (not a script or class), or couldn't be found on base "self".
 modules/gdscript/gdscript.cpp:599 - Method failed. Returning: ERR_PARSE_ERROR
 res://addons/material_maker/engine/gen_material.gd:52 - Parse Error: The method "add_to_group" isn't declared in the current class.
 modules/gdscript/gdscript.cpp:599 - Method failed. Returning: ERR_PARSE_ERROR
 res://addons/material_maker/import_plugin/ptex_spatial_material.gd:16 - Parse Error: The identifier "mm_loader" isn't declared in the current scope.
 modules/gdscript/gdscript.cpp:599 - Method failed. Returning: ERR_PARSE_ERROR
 res://addons/material_maker/import_plugin/ptex_import.gd:64 - Parse Error: Couldn't fully preload the script, possible cyclic reference or compilation error. Use "load()" instead if a cyclic reference is intended.
 modules/gdscript/gdscript.cpp:599 - Method failed. Returning: ERR_PARSE_ERROR
 res://addons/material_maker/plugin.gd:7 - Parse Error: Couldn't fully preload the script, possible cyclic reference or compilation error. Use "load()" instead if a cyclic reference is intended.
 modules/gdscript/gdscript.cpp:599 - Method failed. Returning: ERR_PARSE_ERROR

Steps to reproduce:

  1. Install the plugin from AssetLib.
  2. Attempt to enable it from AssetLib > Plugins...
RodZill4 commented 4 years ago

Material Maker requires a few autoloads for the plugin to work. I started making this smoother for (I hope) next release.

Vivraan commented 4 years ago

What are the necessary autoloads?

RodZill4 commented 4 years ago

mm_io_types="res://addons/material_maker/engine/io_types.gd" mm_loader="res://addons/material_maker/engine/loader.gd" mm_renderer="*res://addons/material_maker/engine/renderer.tscn"

Vivraan commented 4 years ago

I tried adding the autoloads and I got this:

 modules/gdscript/gdscript.cpp:1453 - Condition "!named_globals.has(p_name)" is true.
 modules/gdscript/gdscript.cpp:1453 - Condition "!named_globals.has(p_name)" is true.
 Script does not inherit a Node: res://addons/material_maker/engine/io_types.gd.
 editor/editor_autoload_settings.cpp:488 - Condition "!info->node" is true. Continuing.
 Script does not inherit a Node: res://addons/material_maker/engine/loader.gd.
 editor/editor_autoload_settings.cpp:488 - Condition "!info->node" is true. Continuing.
 res://addons/material_maker/engine/gen_base.gd:222 - Parse Error: Couldn't fully load the singleton script "mm_io_types" (possible cyclic reference or parse error).
 modules/gdscript/gdscript.cpp:599 - Method failed. Returning: ERR_PARSE_ERROR

There's a cyclic reference of this order (upon inspecting the code): MMGenBase -> mm_io_types -> mm_loader -> MMGenBase.

I also noticed that your code adheres to some kind of mixed convention leaving a lot of code ambiguous. The style used is also ambiguous, since I couldn't identify the autoload classes at first glance. I'd suggest sticking with static typing entirely, renaming these autoloads or switching to class_name for them.

RodZill4 commented 4 years ago

The autoloads are singletons, it would be possible to instanciate them explicitely in the plugin and in material Maker, but it would be impractical. It is probably possible to break the dependency loop by adding a new class for material maker paths (that's defined in the loader and used in io_types).

And yes, I often forget to specify types (and I've been using Godot for quite some time and typing was not available when I started this projeect).