def Myfunc():
print "Stuff"
#Title: "CrashLanding"
#By: Python User
#November 16, 2009
#Features improved coding style, or at least I think so
#note:code based on J.G.S'S code-I really learned alot from his code Some credit goes to him
#note:I dont think that is his actual username so keep that in mind
#Can you guys please look over my code? Is it a good coding style? Like i said, its based
#of off J.G.S'S code as i am rather inexp...this is my first real text adventure
#note:crystals same as gold, only i wanted to have a different name for the currency
crystals = 0
gotCrystals_cell=0
gotCrystals_sewer=0
gotCrystals_lair=0
gotCrystals_caves=0
gotCrystals_cavelake=0
crystals_found1=0
crystals_found2=0
crystals_found3=0
crystals_found4=0
crystals_found5=0
dust_movedlair=0
def pass1():
print 'you posess', crystals, 'crystals'
prompt_cell()
def pass2():
print 'you posess', crystals, 'crystals.'
prompt_sewer()
def pass3():
print 'you posess', crystals, 'crystals.'
prompt_lair()
def help1():
print '''The following is the list of commands that you can make.
commands should be written in lowercase font only. north, south, east, west, look(object), look inside(object), help, get(item), use(item), talk(npc), use ship(endgame)'''
print
pass1()
def help2():
print '''The following is the list of commands that you can make.
commands should be written in lowercasef only. north, south, east, west, look(object), look inside(object), help, get(item), use(item), talk(npc), use ship(endgame)'''
print
pass2()
def help3():
print '''The following is the list of commands that you can make.
commands should be written in lowercasef only. north, south, east, west, look(object), look inside(object), help, get(item), use(item), talk(npc), use ship(endgame)'''
print
pass3()
def help4():
print '''The following is the list of commands that you can make.
commands should be written in lowercasef only. north, south, east, west, look(object), look inside (object), help, get(item), use(item), talk(npc), use ship(endgame)'''
print
pass4()
def help5():
print '''The following is the list of commands that you can make.
commands should be written in lowercasef only. north, south, east, west, look(object), look inside(object), help, get(item), use(item), talk(npc), use ship(endgame)'''
pass5()
def began():
print '''You awake to a sudden pain in your side. Looking around, you see that you are inside a dimly lit cell.
You were supposed to be part of a raiding party on Earth but were shot down over City012.
The last thing you remeber before you blacked out was that you saw your ship crashland into the side of a mountain.
If your lucky, your ship could still be flyable thanks to shield technology. But what matters you most is escaping
this cell.
Your ship is powerd by purple cyrstals found naturally on your homeworld.
In order to fly the ship, you'll have to find 30 of them. Unfortunly for you,
the humans most likly took all of them in order to study and then reverse engineer them to power their machines.
Remember, you still have to find the ship before you can put the 30 crystals to good use.'''
cell()
def cell():
print 'you posess', crystals, 'crystals'
print '''Upon studying your cell futher, through the blanket of darkness you can make out a note lying on the ground and a bunkbed.To the north is a sewer,
to the south is a group of caves below the cell connected by a hidden floor door.'''
prompt_cell()
def prompt_cell():
global crystals
global gotCystals_cell
global gold_found1
prompt_cell = raw_input('>')
if prompt_cell == 'north':
sewer_room()
elif prompt_cell == 'south':
hiddendoor_room()
elif prompt_cell == 'north':
caves()
elif prompt_cell == 'look note':
print '''you pick up the note and began to read: If anyone is reading this,I stashed some loot in the bunkbed up against the wall. Don't ask how
I obtained them, but anyone who finds all 30 crystals meet me at once
inside a hidden cave network underneath this facility.'''
elif prompt_cell=='help':
help1()
elif prompt_cell == 'look inside bunkbed':
print '''you lift up the mattress on the bunkbed and as the note clearly stated, you find 5 crystals underneath'''
gold_found1 = 1
pass1()
if prompt_cell == 'get crystals':
#this code will not run. i got this error from the program:
#line 101, in prompt_cell UnboundLocalError: local variable 'gotCrystals_cell' referenced before assignmen]
if gotCrystals_cell == 0 and crystals_found1 == 1:
print '''You get the gold that was under the mattress of the bunkbed.'''
gold = crystals+5
gotCrystals_cell = 1
pass1()
elif gotCrystals_cell == 0 and crystals_found1 == 0:
print '''You don't see any crystals.'''
pass1()
elif gotCrystals_cell == 1 and crystals_found1 == 1:
print '''You do know you already have the crystals, right?'''
pass1()
else:
print '''I don't know how to perform that.'''
pass1()
#I'm going to add the four other rooms and other code later, im burnt after all this typing.
#I hope to add more commands and more layers of difficulty,
#like i want to hide the space ship in several objects, more roms, etc
#but that will have to wait
#began the game:
began()
I need help near the end of my code. Something about an unboundlocalerror. Can you guys look through my code and see if i did
something wrong: this is the "offending" code i think: if gotCrystals_cell == 0 and crystals_found1 == 1:
At first i thought it was the spaces i made but that was not it.
Spent like 40 minutes rewriting it before becoming completly
stumped.
The rest of the code was OK, though.
Much appreciated,
Python User