text adventure game problem!

Thread Solved

Join Date: Apr 2008
Posts: 19
Reputation: IU34 is an unknown quantity at this point 
Solved Threads: 0
IU34 IU34 is offline Offline
Newbie Poster

text adventure game problem!

 
0
  #1
Apr 5th, 2008
yeah, another one...but this time in python! yay, more errors!

first off, here's the code..

(based off of chris99's code...the only example i could find for a text adventure game!)

Now, my problem is where it says
  1. elif prompt_p == 'examine sign':
  2. print """Behold the mysterious grating! For some unknown reason, it will not open until you have 57 gold.
  3. Why the odd number? I don't know...just play along will ya? You won't get out unless you do!"""
  4. prompt_p()

I run the program, and at first it appears to be working. From the start, I can go north to the clear field spot. But from there, no matter what I try to do, it gives me a
  1. Traceback (most recent call last):
  2. File "C:\Documents and Settings\enokar\My Documents\programming stuff\Python\better text adventure test.py", line 56, in <module>
  3. field()
  4. File "C:\Documents and Settings\enokar\My Documents\programming stuff\Python\better text adventure test.py", line 16, in field
  5. prompt_field()
  6. File "C:\Documents and Settings\enokar\My Documents\programming stuff\Python\better text adventure test.py", line 20, in prompt_field
  7. clear_path()
  8. File "C:\Documents and Settings\enokar\My Documents\programming stuff\Python\better text adventure test.py", line 29, in clear_path
  9. prompt_path()
  10. File "C:\Documents and Settings\enokar\My Documents\programming stuff\Python\better text adventure test.py", line 43, in prompt_path
  11. prompt_p()
  12. TypeError: 'str' object is not callable
:note: not actualy username...

anyway, anyone know how to solve this??
Last edited by IU34; Apr 5th, 2008 at 9:14 pm.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 19
Reputation: IU34 is an unknown quantity at this point 
Solved Threads: 0
IU34 IU34 is offline Offline
Newbie Poster

Re: text adventure game problem!

 
0
  #2
Apr 5th, 2008
Yes!! I got it! okay never mind guys...

just to let other people know, I had to change at the end where I called the prompt_p. First I changed everything on that part the prompt_cle, and at the end to call the prompt again I had to put prompt_clear() instead of prompt_p().
Last edited by IU34; Apr 5th, 2008 at 10:29 pm.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 19
Reputation: IU34 is an unknown quantity at this point 
Solved Threads: 0
IU34 IU34 is offline Offline
Newbie Poster

Re: text adventure game problem!

 
0
  #3
Apr 5th, 2008
okay, sorry for _triple_ post...
(new code)

so, my new error message is 'local variable 'gold' refferenced before assignment.'

now what?
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 129
Reputation: hacker9801 is on a distinguished road 
Solved Threads: 15
hacker9801 hacker9801 is offline Offline
Junior Poster

Re: text adventure game problem!

 
0
  #4
Apr 6th, 2008
try putting global gold as the first statement in any function that uses the variable 'gold'
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 19
Reputation: IU34 is an unknown quantity at this point 
Solved Threads: 0
IU34 IU34 is offline Offline
Newbie Poster

Re: text adventure game problem!

 
0
  #5
Apr 6th, 2008
all right! it works now...thanks for explaining it a little bit better to me!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC