I'm not very experienced with web languages, but I know a little bit of JavaScript. I'm working on creating a text-based rpg in HTML and need a way to modify dialogues for main story or quest dialogues and events without editing the code every time.

I know that if it's just to work with plain text, it wouldn't be too difficult. But I want to include a way to associate what type of monster to fight with specific quests or have specific rewards for them.

Is there a way to do this with JavaScript? What is the best way to approach this problem?

  • \$\begingroup\$ Presumably you've considered storing your quest/dialogue data in a common web serialization format like JSON? We can't advise very deeply because we don't know the shape your data takes or what kinds of relationships matter to it. Want to show us how you're authoring a quest or dialogue so far, and we can try to suggest improvements to decouple the code from the data? \$\endgroup\$ – DMGregory Oct 14 '19 at 12:02
  • \$\begingroup\$ I'm not sure how I would load events from JSON. I understand that loading text and objects would be easy but what do I do when I want the player to receive an item or encounter enemies at a certain point in the story? \$\endgroup\$ – Al. Oct 14 '19 at 14:54
  • \$\begingroup\$ What do you do now? You said your problem is in separating the dialogue/quest data from the code, so presumably you have a code solution that's working, just too high-maintenance because you have to edit the code each time you change something? Show us a representative sample of that, and we can guide you in how to maintain the behaviour you have now while separating the data from the code. \$\endgroup\$ – DMGregory Oct 14 '19 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.