|Topic was automatically imported from the old Question2Answer platform.
I’m trying to implement a custom resource type (specifically, a “WorldMap” type, which will first load a “filename.map” file and then load sub-resources as needed according to the contents of the file). Registering the type itself (via a plugin) seems to work fine, but I’m obviously missing a step between declaring the resource type and tying up the “map” file extension so that load() can find it. Right now,
load("res://world/map/default.map") returns the following on the console:
ERROR: No loader found for resource: res://world/map/default.map
Skimming through resource_loader.cpp, I seem to need to implement some
ResourceFormatLoader class and register it with
ResourceLoader? Google gets me exactly zero useful hits for any of this, however.
I’m trying to do this in pure GDscript, but I don’t mind diving into pure C++ code or a mix if that’s required. I’d just prefer not to.
Software used: Godot 3.0 stable mono, 64bit, Windows.
I’m not sure if Godot 3.0 exposes a way to implement custom
ResourceLoaders yet, it’s a problem I am facing too for a plugin I make. Modules can do that because they have access to this system. That should have to be worked on for 3.1 I hope.
In the meantime, you can use exported variables from your custom resource script, and Godot will be able to save them under .tscn or .scn format as usual.
The issue here is not so much saving the resource, but being able to load it at runtime, to facilitate both editing it without having to rebuild the game (or even have the Godot UI open) and future moddability.
I can write a bunch of methods to call instead of
load() to make that happen as a work-around, I’m just not sure bypassing the resource loader like that is a good idea.
Akjosch | 2018-01-31 04:55
If your file is not a resource in the Godot sense, then you should use the
File API instead, not
Zylann | 2018-01-31 19:35
The whole point is that whatever I’m trying to load isn’t a resource in the Godot sense yet - either because it’s game-specific, like the “WorldMap” example or more generally any game level definition, or because Godot simply doesn’t have it in the core, like for example a
Dialogue resource (KAG3 or ChatMapper files) or a
GeographicLayer one (GeoJSON format, for example). And the question is, how can I add it so that Godot’s resource loading mechanisms will behave the same with them as they do with built-in resources.
Akjosch | 2018-02-01 06:47