Saving Games in Python
UmarQureshi4

Hiya!

So, I need help with a function in my game, Stormfront.

Basically, I need a simple way of saving my game using a specific keyword. Is there any answer to my question?

< Umar Qureshi >

You are viewing a single comment. View All
InvisibleOne

The easiest way is just to use replit db.
You can save a key like this:

and then get the value of a key

An example would be saving a dictionary holding the user data

UmarQureshi4

@InvisibleOne

What is the 'import os' for?

ruiwenge2

@UmarQureshi4 import os is to get the user who is running the repl

InvisibleOne

You need os to read env variables, which you use to get the person's replit username with os.environ['REPL_OWNER'] @UmarQureshi4

UmarQureshi4

@InvisibleOne

What about the colons used?

InvisibleOne

For the python dictionary? Those just give the key that value. @UmarQureshi4

UmarQureshi4

If you don't mind, can you demonstrate this in my case - so when the player starts, they are asked to type in their username, and then throughout the game, the player can save their progress. How would that work? @InvisibleOne

InvisibleOne
UmarQureshi4

What does each part of the database section do? Can you label it for me, if you don't mind?

@InvisibleOne

InvisibleOne
UmarQureshi4

Thanks, @InvisibleOne for the help. You were great in helping me solve this problem, and may our paths cross again.

< Umar Qureshi >

@InvisibleOne