godot-visual-script icon indicating copy to clipboard operation
godot-visual-script copied to clipboard

Save VisualScript in a text-based format instead of a binary format

Open aaronfranke opened this issue 5 years ago • 5 comments

This supersedes #16023.

Describe the project you are working on:

https://github.com/godotengine/godot-demo-projects/tree/master/visual_script

Describe the problem or limitation you are having in your project:

The problem is that VisualScript files are saved as binary, not text.

  • Changing binary files in Git is a quick way to bloat the Git history.

  • It's extremely difficult to review changes to VisualScript files if people submit pull requests.

  • It's impossible to rebase and combine changess to VisualScript files in pull requests.

  • It's impossible to share VisualScript files in places that don't allow uploading binary files.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:

Storing VisualScript files as text would fix all of these problems. It would take up less space in Git history when things are changed, it makes changes easy to review, it would become possible to combine changes, and it would allow sharing VisualScript files by pasting some text.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

I propose the file format would be called tvs, and files would end in .tvs. It would behave like tscn or tres, with tvs simply being a text version of vs, and new files are saved as tvs.

If this enhancement will not be used often, can it be worked around with a few lines of script?:

The only workaround is to use built-in scripts, or hack them to save as .tres.

Is there a reason why this should be core and not an add-on in the asset library?:

Even if it could be worked around, this kind of thing must be a part of the engine, because if you send a .tvs file then you'd also need to send the add-on, which defeats some of the point.

aaronfranke avatar May 28 '20 14:05 aaronfranke

Addendum: saving visual scripts as text would probably also prevent/workaround the "corrupting to rscc" issue?

Zireael07 avatar May 28 '20 14:05 Zireael07

I agree with this being a huge problem with git (and other VCS).

Right now, the workaround is to create the file with the .vs file format (as the dialog forbids using another extension) then use 'Save as' to rename it with the .tres extension (and remember to choose all extensions in the save dialog). However, you lose the information from the file format that it's a visual script file.

orion78fr avatar Jul 01 '20 00:07 orion78fr

VS as .tres works 100% fine, on 3.2.3. only thing is that the creation doesn't allow .tres extension when creating a Visual Script... a quick UX fix (to prevent the need for the Save as with all files in the file dialog and rename the .vs to .tres, which is like 3 steps really and it's a one time deal per script) would be to allow the New Script dialog to recognize .tres as a valid format for a Visual Script, as VisualScript.tres works just fine as VisualScript.vs, just with none of the major drawbacks of .vs

If anyone knows where to look (I don't, otherwise I'd probably make a PR to add that, even despite my fairly poor C++ skills) to set the new script dialog to recognize .tres as valid for a new Visual Script, should be a fairly simple change/addition

mrjustaguy avatar Nov 03 '20 15:11 mrjustaguy

https://github.com/godotengine/godot-proposals/issues/1240 is a similar proposal.

fire avatar Jan 06 '22 01:01 fire

I did some tests when trying to create my own module and wanted to share the results.

If you do the following the file is able to be saved and loaded as a text file.

  • Exclude your file extension from being recognised by the binary saver here and here
  • Include your file extension in the text saver here, here and here

I also want to mention the proposal of reduz

While I was not able to actually save My Script as a resource and will probably use a ConfigFile I hope this helps.

Gallilus avatar Oct 28 '23 17:10 Gallilus