r/learnjavascript • u/MeekHat • Aug 26 '26
Not sure how to implement this branching storylines text game idea with Json
Just looking for some experienced feedback.
What I want to do is to import all of this from a file(s):
A list of global variables.
A list of storylines.
Each storyline has a list of local variables and a list of storyline beats.
Each beat has a list of preconditions (which may involve any variable), displayed text, a list of links.
Each link has displayed text, a list of conditions, a list of effects, the id of the next beat.
My problem is that, as I've learned, I can't split this into several files (such as, at least, separate storylines), because you can't import contents of a folder without naming each individual file. So this all has to be in one file, which means it's quickly going to get unmanageable as a Json file.
Should I implement a GUI editor first then? And concurrently a custom parser.
(This is going to be a purely client-side browser game.)
I've already done a simpler prototype, and that was already quite a chore to write in text.
View all comments
Show parent comment
1
u/azhder Aug 27 '26 edited Aug 27 '26
I am telling you you don’t have to insert your own build script if Vue does it by matter of course. All you have to do is understand the concept.
Look at the package.json scripts, see which one is for build, it will look almost the same as the one for dev. Look at all I have written above. Read and re-read until you understand I have already given you the answer. You just have to learn the correct CLI command.
You can also check about asynchronous loading of scripts via the framework.
It may be a lot to lear for you, and I would have written you the solution if I had time and knowledge of your own particular framework, but best Incan give you is a concept I have seen and used in other places that should he available in yours as well.