How to create a resource / save large data from a custom node?

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

I am making a tool for editing a terrain, which produces a large amount of data (height field and meshes). I want this data to be saved, but how can I do it?

Using export in the terrain node looks ood to me, because the data could be a 1024*1024 array of floats.

I could create a new kind of Resource, but again I have no clue how to define a custom one into Godot.

Any ideas?

I really expect your plug in anyway. :slight_smile:
I hope you find a way.

volzhs | 2016-07-31 14:54

I am using export right now, which works pretty well. But I am concerned about huge terrains: size of 512 and above produces .tscn files of several megabytes, as well as a longer loading and saving time :s

Zylann | 2016-08-01 02:00

:bust_in_silhouette: Reply From: timoschwarzer

You could save the Arrays using File#save_var(). This should result in a much smaller file, because the floats will be saved in binary format instead of a serialized String. Then your terrain node could accept a *.terrain file name or something like this.

When can I do that? Which event tell me the scene is saved? And how do I define the custom resource?

Zylann | 2016-08-03 18:47

You could save everytime data has been changed. And you can just define an export var String file path

timoschwarzer | 2016-08-03 19:32

Yeah, but what I want is to be able to define a custom resource one can actually setup as an object, just like any other Resource in Godot. Is there any way to do that now?

Zylann | 2016-08-03 19:41

Sorry, but then I don’t know :expressionless:

timoschwarzer | 2016-08-03 19:53