GraphEdit how to save nodes tree?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By websterek

Hi!
I’m writing Godot tool for editing enemies in my game. Node approach seems to be the best option (and better than my actual table editing).

First part works flawlessly (saving values to arrays) but I have problem: how can I save GraphEdit for latter editing? Should I make it from scratch saving all nodes with offsets, values etc. to some file or there is some more convenient and simple method for that?

can any one can give a demo?

huahuapro | 2020-03-04 00:44

:bust_in_silhouette: Reply From: Zylann

If you want to save exactly the whole branch under which your graph resides, you could try setting the local root as the owner of all graph nodes, and then use PackedScene functionality: PackedScene — Godot Engine (3.0) documentation in English
Please note that this will only save what the editor would usually save. So for example, non-exported vars won’t be considered.

I’d like to mention that, on the other hand, you can indeed save your own format manually, which is a lot more tedious but in some cases it’s more correct because what you want to save is not an edited Godot scene (which may include a lot of things you don’t care about or sometimes can’t even be saved), but a graph for enemies. To better illustrate what I mean here, let’s say you have a spreadsheets app implemented in HTML5. To save a spreadsheet, would you save the whole HTML DOM tree with a JS dictionary? Or would you save an ODS/XLS file?

So there is indeed a simple way to save nodes, just pick the method that you think is better for you :slight_smile: