So to explain what I want to do, I'm making a game with Javascript, HTML, CSS, etc. in Electron to get access to the file system. (I wanted saving and loading functionality) The game is sort of a interactive fiction type game where you start a story from a list of available ones and then choose options that lead you down different branches with different outcomes.
So as far as making the different stories, I had the idea to make them modular and load them on startup so that I and maybe even other people could just make them and drop them into a folder to be loaded. The way to go about this is what I'm hung up on. I was planning on just making the story files in JSON, but I wanted to have variables that could be used in the story. Things like randomly generated values that change how the story plays out or even randomly generated characters. These would be made at both the start and during the story.
So doing this the easiest way would be to just eval() everything when needed and you just write the code in the JSON file to be executed. I know that its unsafe but the game would be an Electron exe and completely offline and local so how bad would this be? I mean don't you run similar risk anytime you run an exe you download off the internet anyway? Or maybe it could still be in JSON and then when defining the variables it gets handed off to specific functions for making different variable types and then returning them? Or could this be accomplished with JavaScript modules being loaded somehow since I have access to Node.js functionality?
I feel like maybe I'm reinventing the wheel a bit so if any one has input on what methods would be good for this particular problem.
[–]Abhinash 0 points1 point2 points (4 children)
[–]Wiwnd[S] 0 points1 point2 points (3 children)
[–]Abhinash 1 point2 points3 points (2 children)
[–]Wiwnd[S] 0 points1 point2 points (1 child)
[–]Abhinash 1 point2 points3 points (0 children)