Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Community] [InkJS] Dialogue tree with InkJS #1158

Merged
merged 11 commits into from
May 26, 2024
Merged

Conversation

infokub
Copy link
Contributor

@infokub infokub commented Feb 4, 2024

Edit gdjs authorization for InkJS extension and add Extension file

Edit gdjs authorization for InkJS extension
@infokub infokub requested review from a team as code owners February 4, 2024 15:58
@infokub
Copy link
Contributor Author

infokub commented Feb 4, 2024

Demo project : https://gd.games/infokubarcade/ink-demo
The story is written in Ink and read by the extension.
The other content (text appearance, choice appearance, backgrounds etc.) are made with regular GDevelop events.

@infokub infokub mentioned this pull request Feb 4, 2024
3 tasks
@D8H
Copy link
Contributor

D8H commented Feb 4, 2024

Thank you for submitting an extension.

A few things before starting the review:

  • The demo must be a project because it allows reviewers to understand how the extension is used.
  • The library should not be minified to let reviewers do a quick check for ill intended code.
  • The library version and a link to the repository should be added in a comment to allow extension maintainers to easily update it.

@D8H D8H added ✨ New extension A new extension 👨‍👩‍👧‍👦 Community extension An extension submission to be merged ASAP with a lightweight review. labels Feb 4, 2024
@4ian
Copy link
Collaborator

4ian commented Feb 13, 2024

Hey - we would love to have this in the extension list. Is there any blocker or things we can help on, on the 3 points of the list written by @D8H?
Happy to discuss!

@infokub
Copy link
Contributor Author

infokub commented Feb 13, 2024

Hey, the only blocker is me not checking my Github account 😐

I'll do this right away so it will be ready for tomorrow morning 👌

@infokub
Copy link
Contributor Author

infokub commented Feb 13, 2024

Maintenance

Ink source : https://github.com/inkle/ink
InkJS : https://github.com/y-lohse/inkjs

Current support :
Ink 1.1.1
InkJS 2.2.0

Not supported :
Multiple flows (beta on Ink side)

@infokub
Copy link
Contributor Author

infokub commented Feb 14, 2024

@infokub
Copy link
Contributor Author

infokub commented Feb 14, 2024

For now i don't know how to not use the minified version since it's the only accessible file i know.
So let me know what i have to do to build a not minified file and i'll push it tomorrow.

@D8H
Copy link
Contributor

D8H commented Feb 14, 2024

For now i don't know how to not use the minified version since it's the only accessible file i know. So let me know what i have to do to build a not minified file and i'll push it tomorrow.

The library uses the Terser plugin of Rollup. I guess you can get a not minified version by removing these lines: terser(),
https://github.com/y-lohse/inkjs/blob/master/rollup.config.js#L2C10-L2C17

@D8H
Copy link
Contributor

D8H commented Feb 17, 2024

Thank you for submitting an extension.

It looks great already. I have a few questions and suggestion:

  • Your example is great to show that the extension is actually easy to use. As the extension has a lot of features, it will probably frighten users if they can't rely on an example. Do you think it could be submitted too?
  • When does a game need several stories?
  • Having to register variables for the VariableChanged condition to work doesn’t' sound user-friendly. Do you think the condition could automatically register the variable observer if it doesn't exist yet? In this case, the condition could return true as users may want to handle the initial value.
  • About ObserveAndConnectVariable
    • Does it work both ways?
    • What happens after a scene change? As it seems that the extension keeps a variable instance that will no longer exist.
    • I think it may be better not to keep this action.
  • ChangeVariableBoolean is missing a function group
  • "n°" is French for "#" but I guess just the number is better.
  • Classes don't need to be affected to a local variable. They can be used directly as in this documentation: https://wiki.gdevelop.io/gdevelop5/events/js-code/javascript-in-extensions/#embed-javascript-libraries-in-extensions
  • GDevelop JS editor understands JSDoc. It will give you better autocompletion.
    https://jsdoc.app/about-getting-started
  • The library should not be defined globally as it could conflict with other extensions. You can remove the library package code and only keep the classes. If you put these classes in the same JS event as your own class, you'll even have autocompletion.

@infokub
Copy link
Contributor Author

infokub commented Feb 19, 2024

* Your example is great to show that the extension is actually easy to use. As the extension has a lot of features, it will probably frighten users if they can't rely on an example. Do you think it could be submitted too?

I could yes of course. I also know that EchoDangler is creating a template around it already.

* When does a game need several stories?

If we are talking about a classic VN. Never.
But if you are making a Quest System you could require to split that into multiple files (one per place for example) and not use the automatic flow of Ink.
I gave this possibility for not adding constraints for devs. But the counterpart is to write the Story ID everytime.
Maybe having a Default ID when it's blank ? Like Layers ?

* Having to register variables for the `VariableChanged` condition to work doesn’t' sound user-friendly. Do you think the condition could automatically register the variable observer if it doesn't exist yet? In this case, the condition could return true as users may want to handle the initial value.

I see what you mean, It's what you need to do with any other languages. I could make this auto yes. Just to be clear : the initial value is already set inside Ink, that's why there is no "Change" event thrown here.

* About `ObserveAndConnectVariable`
  
  * Does it work both ways?

It does it one way and a half.
In fact, you can't edit Ink stuff only using the internal "Change Variable" GDevelop obviously.
But if you use the Change Variable of Ink, it will also cycle through all the observers as well, and edit the Variable since you requested it with this Action.

  * What happens after a scene change? As it seems that the extension keeps a variable instance that will no longer exist.

Absolutely not handheld. You are right.

  * I think it may be better not to keep this action.

It's up to GDevelop.

* `ChangeVariableBoolean` is missing a function group
* "n°" is French for "#" but I guess just the number is better.

Noted.

* Classes don't need to be affected to a local variable. They can be used directly as in this documentation: https://wiki.gdevelop.io/gdevelop5/events/js-code/javascript-in-extensions/#embed-javascript-libraries-in-extensions

* GDevelop JS editor understands JSDoc. It will give you better autocompletion.
  https://jsdoc.app/about-getting-started

* The library should not be defined globally as it could conflict with other extensions. You can remove the library package code and only keep the classes. If you put these classes in the same JS event as your own class, you'll even have autocompletion.

I'll look forward this. It will require for me to re-write the entire extension though.

Side notes :

  • bug in Change Variable Number (return stuff instead of changing it)

@D8H
Copy link
Contributor

D8H commented Feb 19, 2024

  • The library should not be defined globally as it could conflict with other extensions. You can remove the library package code and only keep the classes. If you put these classes in the same JS event as your own class, you'll even have autocompletion.

I'll look forward this. It will require for me to re-write the entire extension though.

To save time, you can do a search and replace into the extension JSON file. But, it seems there is only one occurrence of inkjs. (var story = new inkjs.Story(json);) so it should actually be faster manually (to use gdjs._Ink.Story after moving the lib to a local declaration).

@4ian
Copy link
Collaborator

4ian commented Feb 22, 2024

I wonder if this shows that we should add an easier way to include entire JS files (and .d.ts TS definitions) to extensions.

@D8H
Copy link
Contributor

D8H commented May 19, 2024

Please attach a new version of the demo. It will help with the review process.

@infokub
Copy link
Contributor Author

infokub commented May 22, 2024

New demo
Inky_1.1.0.zip

Copy link
Contributor

@D8H D8H left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks a lot! It should be very useful.

@D8H D8H changed the title Add Community Extension InkJS [Community] [InkJS] Dialogue Tree with InkJS May 26, 2024
@D8H D8H changed the title [Community] [InkJS] Dialogue Tree with InkJS [Community] [InkJS] Dialogue tree with InkJS May 26, 2024
@D8H D8H merged commit 94d5137 into GDevelopApp:main May 26, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👨‍👩‍👧‍👦 Community extension An extension submission to be merged ASAP with a lightweight review. ✨ New extension A new extension
Projects
Status: Added to GDevelop
Development

Successfully merging this pull request may close these issues.

3 participants