godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.1k stars 21.18k forks source link

Support for YARN (port yarn spinner to godot) #3827

Closed blurymind closed 4 years ago

blurymind commented 8 years ago

Here's an awesome interactive dialogue/story editor: https://github.com/InfiniteAmmoInc/Yarn What is yarn? Dialogue editor created for "Night in the Woods" (and other projects) by @NoelFB and @infinite_ammo with contributions from @seiyria and @beeglebug. It is heavily inspired by and based on the amazing Twine software: http://twinery.org/ It's written in html5, multiplatform, awesome and open source!

It exports to json files. Currently they have a c# parser for unity. It is called yarn spinner. Here is some documentation on what it does - the syntax in yarn: https://github.com/thesecretlab/YarnSpinner/blob/master/Documentation/Usage.md

I wish I had enough experience to write a gdscript parser. This is pretty darn awesome and makes it very easy to make interactive stories.

I have contacted yarn's developers and opened an issue at their tracker too: https://github.com/thesecretlab/YarnSpinner/issues/24

Unity can read yarn created json files and turn them into an interactive story - not only dialogues but also writing values and executing functions through the parser - thanks to yarn spinner.

Godot could too - if someone ports yarn spinner to gdscript. Once implemented it can make story type rpg/adventure game development in godot much more accessible! Using yarn to write interactive dialogue and story is a breeze, and it is very very powerful!

willnationsdev commented 7 years ago

With the newly implemented Visual Scripting stuff, I feel like it should be possible for us to extend the functionality of the base GraphEdit and GraphNode objects to create a Yarn interface from within Godot that then has YarnSpinner-like functionality for scripting in-game behaviors...we'd have a long way to go though...especially with the incoming C# scripting functionality

Or then again, we could reduce the overall workload by using the existing Yarn editor to make stuff and then integrate the YarnSpinner interpreter into Godot C# once it's functional.

blurymind commented 7 years ago

Perhaps the c# support that is also coming to godot 3 will further make the task easier and with less need to rewrite code? :)

On 12 Jul 2017 18:41, "Will Nations" notifications@github.com wrote:

With the newly implemented Visual Scripting stuff, I feel like it should be possible for us to extend the functionality of the base GraphEdit and GraphNode objects to create a Yarn interface from within Godot that then has YarnSpinner-like functionality for scripting in-game behaviors...we'd have a long way to go though...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/3827#issuecomment-314809663, or mute the thread https://github.com/notifications/unsubscribe-auth/AGMbVRof-kdLSotY1eTdn2dwbQywnFeRks5sNOkTgaJpZM4HiTW1 .

groud commented 7 years ago

I think such thing should be implemented as a plugin, not as a part of the engine itself.

reduz commented 7 years ago

technically visual script can be perfectly used for this, you just need to create the nodes you nee in gdscript, but you can suspend and resume flow as well as moving around execution yo any custom point

On Wed, Jul 12, 2017 at 5:20 PM, Gilles Roudiere notifications@github.com wrote:

I think such thing should be implemented as a plugin, not as a part of the engine itself.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/3827#issuecomment-314885144, or mute the thread https://github.com/notifications/unsubscribe-auth/AF-Z27p9su3srtyM-qxNFR2cDFxsOSYAks5sNSqlgaJpZM4HiTW1 .

blurymind commented 7 years ago

Will the c# support also be usable by plugins? I was just wondering if that could help, since yarn spinner was written for unity in c#

On 12 Jul 2017 23:32, "Juan Linietsky" notifications@github.com wrote:

technically visual script can be perfectly used for this, you just need to create the nodes you nee in gdscript, but you can suspend and resume flow as well as moving around execution yo any custom point

On Wed, Jul 12, 2017 at 5:20 PM, Gilles Roudiere <notifications@github.com

wrote:

I think such thing should be implemented as a plugin, not as a part of the engine itself.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <https://github.com/godotengine/godot/issues/3827#issuecomment-314885144 , or mute the thread https://github.com/notifications/unsubscribe-auth/AF-Z27p9su3srtyM- qxNFR2cDFxsOSYAks5sNSqlgaJpZM4HiTW1 .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/3827#issuecomment-314888046, or mute the thread https://github.com/notifications/unsubscribe-auth/AGMbVS1Ut31b2gBIAWRrSrSsmTKVKX6aks5sNS1ngaJpZM4HiTW1 .

willnationsdev commented 7 years ago

Well, as far as I can tell, it is written in C# generally and has a way to integrate with Unity specifically (there is a particular "Unity" directory in the YarnSpinner GitHub repo). And yes, we could always create a plugin that has C# scripts for Godot, but I'm not sure to what extent those C# scripts can import and use other C# code...anyone have an answer for that?

The worst possible scenario would be if we had to re-write the YarnSpinner interpreter in C++ somehow and then provide access to it via GDNative (would be a lot of work).

I DO think that it would be a major implementation advantage to re-implement the Yarn interface using the GraphNode/GraphEdit user interface. It would allow us to view the content as it is executing based on what @reduz said. It would be ideal if we could be running a game and have it start a breakpoint whenever a certain dialogue line is arrived at, etc.

However, short of actually implementing it IN a .vs file of some sort (as in, using the Visual Scripting interface completely - which isn't really the goal since you can't do [Hey, thanks|NextNode] formats in text to generate new connections), I'm not really sure how one would even hook the Control nodes to the execution flow. I've tried using them individually for a new editor plugin and I can't really seem to figure out how to use them with input/output parameters, etc. If anyone wants to direct to some documentation on them (if there is any), that'd be awesome.

To me, it looks like the GraphEdit is just a Panel that can zoom in/out and change the density or show/hide the grid background. The GraphNode appears to just be an element with a title section that can be dragged around. Even if you manually place GraphNodes in a scene though, running the scene will just automatically position every node at (0,0) - that's probably a bug.

willnationsdev commented 7 years ago

Just found this: https://github.com/StraToN/godot-dialogtreetools

Seems like it is an excellent starting place from which to design a Yarn/YarnSpinner variant for Godot's Visual Scripting GUI. I'm currently thinking of creating a Yarn Parser in GDScript, likely using RegEx, and then just having a base Yarn node that has a title and a textbox, procedurally generating other nodes/connections/etc. from the content you type in. Basically the same way I imagine Twine working (since I've used that before), but using the Yarn syntax.

naturally-intelligent commented 6 years ago

FYI I've built a Yarn importer for Godot:

https://github.com/naturally-intelligent/godot-yarn-importer

It's just a start but it works! Not sure if it's a good idea to make it a built-in feature of Godot because what people might do with a Yarn file is very open-ended.

blurymind commented 6 years ago

@naturally-intelligent All thats left is for someone to implement a usable parser :) Here is a link to the tests that your parser must pass: https://github.com/jhayley/bondage.js/tree/master/tests/yarn_files

Calinou commented 4 years ago

Closing, as this kind of feature is best implemented in a third-party plugin (it should already be feasible). See https://github.com/naturally-intelligent/godot-yarn-importer for a proof of concept.