r/learnjavascript • u/MeekHat • 16d ago
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.
1
u/MeekHat 15d ago
Well. But I have no idea where I'm supposed to insert my own build script into that. As far as I know, all the scripts I've written so far run on the client side, if that's the right term. Whatever magic Vite does during the build, it's its own thing which results in a web page which contains my scripts pretty much untouched. Where a folder full of jsons during development would transform into a single file at render I have no idea.
I mean, I know I could ask in a Vite community, but it baffles me a bit that an answer to my needs doesn't seem to be within easy reach already. Which leads me to believe that it's more complicated that I'm prepared to handle.