Godot: Save VisualScript as text?

Created on 24 Jan 2018  路  15Comments  路  Source: godotengine/godot

Godot 3.0 RC2

I gave a try to VisualScript in order to help someone on Q&A, but I realized I could not share my script because:

  • Images and archives can't be uploaded on the website,
  • Third party upload services could have the file expire (tried Imgur but can't even embed correctly)
  • An image may not show all of the setup I did (inspector, scene etc)

So I thought I could just paste the contents of the .vs so the user could get my VisualScript, but they are currently saved as binary...

That might sound like an irrelevant request, but could they be saved as text?

archived discussion feature proposal visualscript

Most helpful comment

Actually, visualscript can be saved as text: Just make the script built-in. Here is how it appears in the .tscn file:

[sub_resource type="VisualScriptFunction" id=8]
resource_name = "_ready"

[sub_resource type="VisualScriptBasicTypeConstant" id=9]

[sub_resource type="VisualScriptBuiltinFunc" id=10]
_default_input_values = [ null ]
function = 55

[sub_resource type="VisualScript" id=11]
data = {
"base_type": "CanvasLayer",
"functions": [ {
"data_connections": [ 1, 0, 2, 0 ],
"function_id": 0,
"name": "_ready",
"nodes": [ 0, Vector2( 0, 0 ), SubResource( 8 ), 1, Vector2( -40, 80 ), SubResource( 9 ), 2, Vector2( 180, 40 ), SubResource( 10 ) ],
"scroll": Vector2( -50, -100 ),
"sequence_connections": [ 0, 0, 2 ]
} ],
"signals": [  ],
"variables": [  ]
}

So it surely wouldn't be that hard to make the .vs format do that same?
This is the same with materials.

All 15 comments

How about save it as full rez image? Like a screenshot.

@trollworkout I would suggest opening another issue for it, since text and image saves of visualscripts would have different purposes (text to store or share it, image to show it off)


That might sound like an irrelevant request, but could they be saved as text?

I doubt it is irrelevant, especially when this would be useful for Git diffs 馃槂.

@bojidar-bg the storing of it as text for versioning / diff purposes does indeed seem relevant 馃拑

@bojidar-bg actually, you may be able to save as image AND text at the same time:

Developers of the game Parkitect explain in a blog post how they encoded data in pictures. They use it to share user creations with simple images. The trick is to modify the top left corner pixels by certain values to write data.
It is not a perfect solution (especially if the image is altered by hosting websites) but it might be an alternative to think about.

http://themeparkitect.tumblr.com/post/126855975857/update-58

IMO, UE4's Blueprints handle this very nicely: The files are just XML, so you can always copy/paste them, and you can even just select nodes or parts of your scripts and copy/paste those.

you could also convert the visualscript to a slightly modified gdscript and share that

if an image is generated I'd want it stored outside of the project, like in a godot cache or folder in My Documents instead so it doesn't get checked into source control or recognized as a useable asset for sprites. I'm for VS saving as toml formatted files like everything else has been doing so Godot doesn't have to add more format parsers.

I didn't actually realize visual script was a different format all together, I thought it transpiled to GDScript, kind of like how LunaLang is mostly just a UI toggle. Would be nice to turn it into something more like that.

I'm also looking forward to this feature! I really don't like how visual scripts are saved as binary, and you can't make any changes to them in a text editor in case that's ever an easier solution. You have this choice with resources (res / tres), also with scenes (scn / tscn), I see no reason why not to have it with scripts as well (vs / tvs).

Do you know if it's possible to convert between gdscript and visual script automatically as mentioned by trollworkout ? That's another solution to this problem. It's probably too difficult though.

The current problem with visual script adoption is that everyone writes in gdscript. So there aren't a lot of visual scripts.

@fire that would also be a great feature. Although it sounds a bit more complicated.

Any updates on this? Text based .vs files would make it usable in big projects that use version control, and binary files are what are currently holding me back on using it for projects.

Here's a chat log of the text based resource for visual script I posted as an issue.

https://github.com/godotengine/godot-roadmap/issues/30

Actually, visualscript can be saved as text: Just make the script built-in. Here is how it appears in the .tscn file:

[sub_resource type="VisualScriptFunction" id=8]
resource_name = "_ready"

[sub_resource type="VisualScriptBasicTypeConstant" id=9]

[sub_resource type="VisualScriptBuiltinFunc" id=10]
_default_input_values = [ null ]
function = 55

[sub_resource type="VisualScript" id=11]
data = {
"base_type": "CanvasLayer",
"functions": [ {
"data_connections": [ 1, 0, 2, 0 ],
"function_id": 0,
"name": "_ready",
"nodes": [ 0, Vector2( 0, 0 ), SubResource( 8 ), 1, Vector2( -40, 80 ), SubResource( 9 ), 2, Vector2( 180, 40 ), SubResource( 10 ) ],
"scroll": Vector2( -50, -100 ),
"sequence_connections": [ 0, 0, 2 ]
} ],
"signals": [  ],
"variables": [  ]
}

So it surely wouldn't be that hard to make the .vs format do that same?
This is the same with materials.

This would help with https://github.com/godotengine/godot/pull/23310#issuecomment-512819557, since currently VisualScript enums are very brittle and just store integers. Storing functions by name in a text file would be much better.

Feature and improvement proposals for the Godot Engine are now being discussed and reviewed in a dedicated Godot Improvement Proposals (GIP) (godotengine/godot-proposals) issue tracker. The GIP tracker has a detailed issue template designed so that proposals include all the relevant information to start a productive discussion and help the community assess the validity of the proposal for the engine.

The main (godotengine/godot) tracker is now solely dedicated to bug reports and Pull Requests, enabling contributors to have a better focus on bug fixing work. Therefore, we are now closing all older feature proposals on the main issue tracker.

If you are interested in this feature proposal, please open a new proposal on the GIP tracker following the given issue template (after checking that it doesn't exist already). Be sure to reference this closed issue if it includes any relevant discussion (which you are also encouraged to summarize in the new proposal). Thanks in advance!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Zylann picture Zylann  路  3Comments

RebelliousX picture RebelliousX  路  3Comments

mefihl picture mefihl  路  3Comments

gonzo191 picture gonzo191  路  3Comments

testman42 picture testman42  路  3Comments