hi

i am a bit of a noob at python but am trying to make a desicsion making game (a bit like zork).
i was wondering if anyone knew how i could get the palyer to go to a previouse part of the game without writing it all out again?

thanks

fred

Recommended Answers

All 6 Replies

Could you give sample of your coding, say one function with proper docstring documentation, so maybe we can give you advice on your style.

Could you give sample of your coding, say one function with proper docstring documentation, so maybe we can give you advice on your style.

thanks for replying

my coding and stuff isn't very good but i shall give an example:

if z == str("yes"):
   print e      #"you are in a wood..." 
   y = raw_input("what will you do? ")
if y == str("climb the boulder"):
   y = t #"you find a sword..."
   print t
elif y == "walk to fork":
    y = g "you walk to fork..."
    print g
elif y == "walk off path":
     y = f #"spider! ahhh!!!...."
     print f
if y == f:
   dice = (1, 2, 3, 4, 5, 6, 0)
   numberspider = random.choice(dice)
   numberyou = random.choice(dice)
if y == f:
   print numberspider + 1 
   print numberyou - 1
if numberspider > numberyou:
   y = j #"you have won"
   print h - 1
   print j
elif numberspider <= numberyou:
   y = i #"you have lost"
   print h + 1
   print i
raw_input("press<enter>")

this is just a part of it.

e,f,g ect are different places.

thanks for the help

Text adventure game I see. Developing one from scratch is difficult. I have plenty of experience ;)

I've written about it:
http://thekks.net/916

Also I've created an engine, click the link in my signature.

(Wow I feel shameless and dirty. I think I might take a shower...)

hhhhmmmmmmmmmmmmmmmmmmm ;)

i'm having another problem and was wondering if you guys could help? if the player has the dark sword, the following error message comes up

"if numberspider > numberyou:
UnboundLocalError: local variable 'numberspider' referenced before assignment"

i don't know why...it works fine if the person doesn't collect the dark sword.
please please help!

def sub_spiderfight1():
     if ii == []:
        print q
        dice = (1, 2, 3, 4, 5, 6, 0)
        numberspider = random.choice(dice)
        numberyou = random.choice(dice)
        print numberspider + 1 
        print numberyou - 1
     elif ii == ["dark sword"]:
          print "spider! ahhh!!!!! you must defend yourself with the dark sword.!"
          dice = (1, 2, 3, 4, 5, 6, 0)
          numberspider = random.choice(dice)
          numberyou = random.choice(dice)
          print numberspider + 1
          print numberyou + 2
     if numberspider > numberyou:
        uuuu = j
        print h - 1
        print j

i'm having another problem and was wondering if you guys could help? if the player has the dark sword, the following error message comes up

"if numberspider > numberyou:
UnboundLocalError: local variable 'numberspider' referenced before assignment"

i don't know why...it works fine if the person doesn't collect the dark sword.
please please help!

Maybe this helps:

def sub_spiderfight1():
     dice = (1, 2, 3, 4, 5, 6, 0)
     numberspider = random.choice(dice)
     numberyou = random.choice(dice)
     if ii == []:
        print q
        print numberspider + 1 
        print numberyou - 1
     elif ii == ["dark sword"]:
          print "spider! ahhh!!!!! you must defend yourself with the dark sword.!"
          print numberspider + 1
          print numberyou + 2
     if numberspider > numberyou:
        uuuu = j
        print h - 1
        print j
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.