I'm using a lot of resources in my project so my fales became really confusing very fast. So I want to have some resources with a custom extension. Researching about this I ended up creating those custom ResourceFormatSaver and ResourceFormatLoader:

dialogue-format-loader.zip
945B
func _save(resource: Resource, path: String, _flags: int) -> int:
	if not (resource is Dialogue):
		return ERR_INVALID_DATA
	var file = FileAccess.open(path, FileAccess.WRITE)
	if file:
		var result := var_to_str(inst_to_dict(resource))
		file.store_string(result)
		return OK
	return ERR_CANT_OPEN

This method "works" but it turns my resource into a string dictionary, which makes it lose some functionality like opening in the inspector, appearing in the FileSystem or the possibility to drag and drop in an exportedvariable of my Resource's type (Dialogue).

So I'm wondering if there is a way to use the same _save() logic as the one being used by Godot for Resource files. Same thing with _load(). I don't mind if they are identical since all I want is a regular resource file but with my .dialogue extension.

Is this possible to do without modifying the engine? Thanks beforehand!

  • xyz replied to this.

    Godoten How about just using a naming convention, for example:
    foo_dialogue.tres
    bar_dialogue.tres

      xyz I guess I could add "_dialogue" to my path but it doesn't look as good. :/

      • xyz replied to this.

        Godoten You can also use sub folders and put all dialogue resources into /dialogue folder etc. 🙂