Use a string as the file name

I have created several JSONs for the game’s dialogues and would like them to be automatically selected depending on the language and scene.
When I select the name of the file to upload it is considered the exact name of the file and does not allow you to insert strings … Is there a way to do this?

Looks like you will need one action per language.
Or perhaps, you make one big json for all languages and call the branches depending on scene/language.
I agree it’s not ideal.

1 Like

Thanks for your help, Gruk…
…Even when you write me what I don’t want to read. :slight_smile:

In theory, you could make a global structure variable, then put each json’s content as children variables (named for the language), then dynamically build the name of the child variable.

You’d potentially have some massive child variables, not sure if there is any performance concerns, but I don’t think so?

Edit: you would also need to copy the global variable to a scene variable each scene, but that is only one action.

1 Like

Good idea, thank you.
Using Yarn I preferred to distinguish everything within a single JSON.

Then you would need events for each language telling it which branch to start with. That would be unrelated to the json name altogether.

…Why? I use a single event to start dialogue with node name [language string] + “node name”

Ex. it-welcome for italian or en-welcome for english…

I’m confused at what we are discussing, your original question was about dynamically naming the json files in the load event as needed.

That wouldn’t apply if you are only using one json file. Which is what my comment above was referring to.

Edit: if you are using one JSON file with unique branches for each language, you can just use the “Start dialogue from branch” action, and dynamically build the branch name by adding in a variable you set when the user selects their language.

My confusion is cleared up, sorry. You were originally wanting to not use a single file, and then a single file was suggested as a solution.

I’d say your best bet would be to build out your json file, copy the content, and load the full json string into a global structure variable as a child for each, if the desire is to avoid a single json.

1 Like