I am having trouble with python. I am making a text-based adventure game, and I am trying to make a restart function when you die. I am trying to count deaths by doing deaths = deaths + 1 whenever you die, but the only way to restart is to re-run the entire script, which resets the death counter. Does anyone know how to restart a script without re-running the program?
You can call your script from another script, and when you "restart", use the reload built-in method.
This isn't truly ideal though for a game. What you're instead looking for is a level loader, with a main loop which handles state.
Does that make any sense? Its a fun challenge building your own level loader, and might be more effort than you want to put in.