
January 2nd, 2013, 12:31 AM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 1
Time spent in forums: 36 m 36 sec
Reputation Power: 0
|
|
|
How would I switch python files and run code from those files?
I'm fairly new to Python, with a fairly simple question. I'm trying to make a simple text game in Python, kinda like Zork, just to play around with the code. I wondered if I could do something like this and how:
there'd be a few files, like this:
start.py
otherfile.py
And this would happen. start.py would run fine and dandy, then when a certain thing happens (such as the player proceeds far enough for a certain variable to become True), it would run otherfile.py, instead of having all of the levels in one file. Is this possible? And how about a global variable shared between all files, such as the player's name, is that possible? I understand python syntax and understand enough to do some things within one file, but nothing like using multiple files.
Storing certain things like journal entries for when the player picks one up to read in its own file would be pretty neat too.
Sorry if I sound like a noob because I pretty much am, lol. Don't be harsh. This is also probably more work than i'm making it sound.
|