Can a plugin resource be exported as a variable type?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Brandon Hustus
:warning: Old Version Published before Godot 3 was released.

Hi all-
I’ve created a custom resource plugin so I can keep a palette of colors that can be modified in one location and effect everywhere relevant. But when I try to export it with the type hint, BlockColors, it returns an error: error(17,7): Export hint not a type or resource.

Here are my files:

res://addons/block_colors/plugin.cfg

[plugin]

name="BlockColors"
description="A custom resource which holds a color for each Tetromino type"
author="Brandon Hustus"
version="1.0"
script="block_colors_plugin.gd"

res://addons/block_colors/block_colors_plugin.gd

tool
extends EditorPlugin

func _enter_tree():
	add_custom_type(\
	"BlockColors",\
	"Resource",\
	preload("block_colors.gd"),\
	preload("res://Blocks/Tetris Block.png")\
	)

func _exit_tree():
	remove_custom_type("BlockColors")

res://addons/block_colors/block_colors.gd

extends Resource

export(Color) var I_block_color
# More to be added later

When I try to export(BlockColors) in another script, it returns the error listed above. I have enabled the plugin and am able to create a resource of the BlockColors type. Have I done anything wrong, or is it just not possible to export a plugin resource type?

:bust_in_silhouette: Reply From: avencherus

I’m not all that familiar with the source code, but if it doesn’t add user defined types to the built-in types for the parser, then export is going to adhere to only built-in types.

I was curious as well, but this is as far I could find:

Really? I’m not sure if that’s a technical necessity in the code but it seems awfully short-sighted that they would let you make a resource without being able to use it in scripting. I’ll wait around for a bit but if I don’t find anything else I guess you have it!

Brandon Hustus | 2016-10-09 18:16

I hear you on that.

Though it’s a budding engine, there are many things in the works or overlooked. I recall reading some threads of requests wanting to include arrays as part of export, and some interest in having export provide categorization. I get the impression that in it’s current state it’s as hard coded as it appears for the time being.

avencherus | 2016-10-09 19:21

Incidentally, I managed to make it work just by export(Resource) and using duck typing, but I still wish that I could expect the specific type.

Brandon Hustus | 2016-10-10 01:53

Nice work.

Yeah, I imagine it’s less than ideal.

It’s unfortunate that GDScripts can’t extend from Color.

avencherus | 2016-10-10 05:25