Ask coding questions

← Back to all posts
How to implement a save/load system to a game?
mkhoi (198)

I am making a game and want to have a save/load system because it is frustrating without the save/load system (its a long game and also it has permadeath but if i have the save/load system it won't have permadeath)

Check it out:
The Wacky Warrior, its on Challenge

Someone please help me!!!

Answered by ash15khng (393) [earned 5 cycles]
View Answer
Commentshotnewtop
ash15khng (393)

You could let the users download a file, with their progress in it (to save), and add a load function (to load the text in the file).

mkhoi (198)

@ash15khng What is the specific instructions for that?

ash15khng (393)

@mkhoi You could create a JSON object or whatever you want, then write it into a file like this:

save = <whatever you need however you want to save it>
with open("file.txt", "w") as f:
  f.write(save)
mkhoi (198)

@ash15khng What about the load function?

ash15khng (393)

@mkhoi You get it as an input, then save it to your variable(s).

mkhoi (198)

@ash15khng I dont understand that. How do you do that?

ash15khng (393)

@mkhoi

load = input("Save string: ")
load = <however you're saving your game data>
PAULX (17)

at python you can make it with the modul "repl.it" i don't have use this module ever but i have see it in codes from other peoples. as fare as i know it asks you about your replt.it name and password.

mkhoi (198)

@PAULX I want to save a game character or whatever but interesting information though

TheDrone7 (560)

You will need to setup a database, if you're familiar with JSON format of data storage then use mongodb otherwise you can also use some or the other distribution of SQL. You won't be able to save data on files in repl.it

mkhoi (198)

@TheDrone7 Guess i will need to learn that...

TheDrone7 (560)

@mkhoi if you're going for mongodb then it's going to be very easy to learn how to use the DB, although it won't be that easy to connect your DB to your app but it's not very difficult either.