I'm making a text-based adventure game which I plan on being quite long. Naturally, instead of having all the code in main.py
I decided to split the chapters into different files to be run in if
blocks according to the choices the player makes. Slight problem, however: all of the user information I'm using to customize the story (name, gender, clothing, etc.) is stored in main.py
.
So, if I have another file (let's say option3.py
for example) and I'm writing something like
print(f"{user_name} walked down the street.")
I don't have user_name
stored in option3.py
. I'd rather not import specific variables into each of the 20+ files every time but I hear that sharing namespace is a bad idea, so I'm wondering if there's a better way to work around this.
Extra: I'd also like to include some sort of item inventory feature but I'm not sure how to go about that, what with this multiple file issue and the fact that the inventory would often change