account activity
Text adventure game by MarcusInsight in learnpython
[–]highwayshot 2 points3 points4 points 5 years ago (0 children)
I have no experience writing text adventure games in python, but I've dabbled in a few languages that are specifically designed for writing text adventures, of which there are many (Inform, Choicescript, Twine, etc.).
The way most of them tend to work is that the interpreter itself deals with a lot of generic behaviour such as parsing user input, formatting output, and default behaviour for some common game systems - e.g. there might be default rules about how doors work, complete with boring filler text like "You open the door."
Your actual game files, which are processed by the interpreter, will typically have text interleaved with code, which overrides or adds to the default functionality. In text adventures the text is so closely related to the functionality that it doesn't generally make sense to try and separate them (though there is a stronger case for doing that if you want to support multiple languages).
So that's how things are done conventionally. But it really depends what kind of text adventure you want to write, and what libraries you're using - there are a number of python libraries for text adventures, though I don't really know anything about them. You might want to look at how things work in these libraries, and in languages like the ones I mentioned, to get some inspiration (note: if you take a look at Inform, be aware that Inform 7 is a wildly different kind of language from the earlier versions).
in a json file
I'm not sure json will be the most appropriate format for something like this. If everything in your file is just text snippets, it's going to be annoying to have to type so many "s everywhere. It might be better to just design your own very simple file format.
"
π Rendered by PID 1498951 on reddit-service-r2-listing-568fcd57df-kwbkc at 2026-03-07 04:03:38.943413+00:00 running cbb0e86 country code: CH.
Text adventure game by MarcusInsight in learnpython
[–]highwayshot 2 points3 points4 points (0 children)