GDevelop
GDevelop copied to clipboard
Add better structured variable support to DialogueTree extension
Description
It would be nice if DialogueTree could accepts structured (object) variables, even though I am not entirely sure how it would work. Just raising this here to test the waters before attempting to make a PR i guess
Solution suggested
On the gdevelop side - I am not sure if we can tell gdevelop to pass a structured variable to an extension. Does the api allow for the selection of this type?
bondagejs technically doesnt limit you to what can be saved/loaded https://github.com/hylyh/bondage.js/blob/master/src/default-variable-storage.js
the yarn language however I believe uses flat structure for variables. I need to do some digging to see if bondagejs also allows deserializing nested structures https://v1.yarnspinner.dev/docs/writing/expressions-and-variables/
{
myVariable: {
childVariable: 123
}
}
becomes
<<if $myValiable.childVariable >>
if it doesnt, one idea is to simply let the dialogue tree extension do that part, where it actually still uses a flat structure, but uses dot or something else to serialize/deserialize nested keys?
Anyways I would be interested if this is something that would be desired by the community. I personally would like to improve it in order to make it easier to build an entire visual novel type game where all game data is persisted by yarn itself (loading/saving from one place)
I think while we have this awesome extension, it would be good to really stress it by trying to build an entire visual game engine with it in gdevelop. I am finding it difficult when trying to do this with a flat structured data
I am thinking of adding something like this in dialoguetools
https://codepen.io/blurymind/pen/wvZzggG?editors=1112
It will enable storing actor stats or inventory in a structured way, that can then be used for implementing UI in gdevelop. So if you do this in yarn:
// init
<<set $c.tom.outfit = work_suit>>
<<set $c.maya.outfit = winter_coat>>
<<set $c.tom.mood = happy>>
<<set $c.maya.mood = sad>>
to build a HUD in Gdevelop, you will be able to dig into "c" and loop over all existing characters ([tom, maya]), then you can loop over each stat ([outfit, mood])
Keeping that stuff in yarn state greatly simplifies persisting it and kills the possibility of copy pasta errors
experimenting with this now in a javascript event - i was able to extend the dialogtools functionality without even running gdevelop in dev mode, which is excellent :D
It does work very nicely, but i am hitting one pesky limitation: Gdevelop's ui extension framework doesnt allow custom expressions to return an array @Bouh @4ian is that something that is there but hidden? I wonder if there is a way around it?
is this advances nested variables functionality in yarn state something that would be beneficial to pr to gdevelop? I just wonder if its worth spending the time to create a demo and make a pr to dialoguetools to add these extra utility methods/expressions I am making..