If your code's more than 10 lines long or so, put it on <a href="http://pastebin.com">pastebin.com</a> and send us the link rather than inlining the whole thing. You could also send it as an attachment.<div>Your formatting is all screwed up and I can't read the code at all, but I have an idea about your error.<br>
<div><br><div class="gmail_quote">On Wed, Sep 30, 2009 at 8:53 PM, Corey Richardson <span dir="ltr"><<a href="mailto:kb1pkl@aim.com">kb1pkl@aim.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Here is my code that is being used/affected by the block that is erroring. The rest is superfluous, and does not affect it:<br>
<br>
intel = 10 #Define the abilities.<br>
strn = 10<br>
con = 10<br>
dex = 10<br>
wis = 10<br>
exp = 0<br>
cha = 10<br>
playHp = 20<br>
melWep = 1 # A sword<br>
rngWep = 1 #A bow<br>
attack = dex+strn/2 #If they hit!<br>
melDmg = strn+1+melWep/2 #Melee damage<br>
deff = (con/3)+(dex/2)+6 #Defense<br>
rngDmg = dex+1+rngWep/2 #Ranged damage<br>
print "You are hiking through the woods one day, and you are jumped<br>
by a goblin!" #The beginning of the adventure<br>
print "Do you want to 1. Attack w/sword, 2. Attack w/bow, 3. Flee,<br>
or 4. Nothing"<br>
gob1Hp = 10 #First monsters hitpoints<br>
def monsAttk (damage, attack,playHp): #A monsters attack if attack > deff: #Monster hit playHp -= damage #Player takes damage (I think...I will have<br>
to work that out)<br>
print "You have sustained", damage, "damage, with",<br>
damage-playHp, "remaining" #Inform player of their status<br>
def gmAttack(monHp, monDef, monAgil) : #A player attack<br>
op1 = raw_input("Your choice?")<br>
while op1 != "5": #Just a loop that you can break out of<br>
(possibly...working that out) if op1 == '1': #Option 1<br>
if attack + 10 > monDef : #If the player hits<br>
monHp-= melDmg #Monster takes damage<br>
print "you did", melDmg, "damage! It now has",<br>
monHp, "health left!" #Inform player how much health it has.<br>
monsAttk(4, 15) #Monster attacks elif op1 == '2': #Option 2 if attack + 10 >monDef: #If you hit the monster<br>
monHp -= rngDmg #Monster takes damage<br>
print "you did", rngDmg, "damage! It now has",<br>
monHp, "health left!" #Inform player how much health it has monsAttk(4, 15) #Monster attacks<br>
elif op1 == '3' : #Option 3<br>
if attack + dex > monAgil : #If they can escape print "Thou hast fled!" #They have fled!<br>
break #Stop the loop (I think. Can someone please inform<br>
me as of how this works? I have looked online...it makes no sense to me)<br>
elif op1 == '4' : #Option 4...the dumb one<br>
monsAttk(4, 15) #Monster attacks<br>
monsAttk(4,15) #Monster attacks again, cause they are dumb<br>
print "You should attack..." #Inform them of their stupidity<br>
else : #Well, what the hell did they pick?<br>
print "Unknown option, try again!" #Inform them they<br>
didn't pick a valid option<br>
while gob1Hp >= 0: #Well it is still alive<br>
gmAttack(gob1Hp,13,15) #player attacks<br>
if gob1Hp <= 0.5 : #if it dies<br>
print "Gratz! You have gotten 5 exp! You only have", 100-exp,<br>
"exp left till lv 1!" #print their experience<br>
exp += 5 #Give them exp<br>
<br>
<br>
If you catch an error besides what is wrong, please don't point it out, as I would like to work it out myself, unless marked in the comments. But this one is evading me...I have playHp defined at the beginning, and I am getting this error :<br>
<br>
Traceback (most recent call last):<br>
File "C:\Users\Quick-Start\Documents\Python Doc's\Game_File.py",<br>
line 183, in <module><br>
gmAttack(gob1Hp,13,15)<br>
File "C:\Users\Quick-Start\Documents\Python Doc's\Game_File.py",<br>
line 167, in gmAttack<br>
monsAttk(4, 15)<br>
File "C:\Users\Quick-Start\Documents\Python Doc's\Game_File.py",<br>
line 157, in monsAttk<br>
playHp -= damage<br>
UnboundLocalError: local variable 'playHp' referenced before assignment<br>
<br>
If you could please help me, that would be great. I'm just trying to get the game engine working, as of now, it is 30% done, with Inventory, Equipment, and a more sophisticated and simpler code to come. It's a bit of a mess now...<br>
<br>
<br>
<br>_______________________________________________<br>
Tutor maillist - <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
<br></blockquote></div><br></div></div>