[Tutor] Help
> Ok, I am somewhat new to python, and I am making a text-based RPG. I get a > weird error with this code: > > > #A Python text-RPG > #A Jak Production > #APOC > global ammo > global health > global lives > global exp > global food > ammo=55 > health = 100 > lives=10 > exp = 0 > food = 30 > > def part1(): > print "50 Days After The Outbreak:You are standing outside of the Empire > State Building." > print "Vines, plants, dirt, and grime cover its once-regal surfaces. > Huh." > print "I guess if 80% of the world is dead, more people are concerned > about survival than sightseeing.God." > print "Generally,us survivors tend to band together. Mostly it is for > good. Not the bandits." > print " Bandit:'Hey you! What you got in that bag?" > print "I recognized this Bandit as Sam Cabelo. He was the janitor at my > office building. Not the nicest fellow." > answer = raw_input("Type 'show' or 'run away' then hit the 'Enter' > button.") > if answer == "SHOW" or answer == "Show" or answer == "show": > print "Ahhh. Nice .45 you got there. And some food.Hand it over.(He > says this like a threat, reinforced by that revolver in his hand" > answer2 = raw_input("Type either Hand it over or flee") > if answer2 == "HAND IT OVER" or answer2 == "Hand it over" or answer2 > == "hand it over": > print "Bandit: Good Job.. Go on now" > ammo=ammo-15 > food=food-10 > return answer3 > if answer2 == "FLEE" or answer2 == "Flee" or answer2 == "flee": > print "He shot you" > lives=lives-1 > else: > print "TYPE SOMETHING CORRECTLY" > return part1 > > elif answer == "run away" or "Run Away" or "RUN AWAY": > print "He shot you... hee hee hee" > print "When the input comes up again, type a differet answer" > else: > print "You didn't type Show or run away." > part1() > > part1() > > > Here is my error, if it helps > > Traceback (most recent call last): > File "C:\Users\Jack\Desktop\game2.py", line 45, in > part1() > File "C:\Users\Jack\Desktop\game2.py", line 28, in part1 > ammo=ammo-15 > UnboundLocalError: local variable 'ammo' referenced before assignment > > > Thanks, > Jack Little ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help please!
Hi Tutor, I'm getting this error Traceback (most recent call last): File "C:\Users\Jack\Desktop\python\g.py", line 45, in path_1pt1() NameError: name 'path_1pt1' is not defined With the attached file Please get back to me Thank you g.py Description: Binary data ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Please help
I do not understand my error (it says something about an out-of-function return on line 179) my code is at the link http://www.mediafire.com/download.php?4ga0weu4ifc6s1u___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Please help
Maybe tomorrow I can just email you the code ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Here is code, no link for my previous question
Here is the code, my error is below the code in itallics #This is not free source #Don't cheat by looking at this #If you do you ruin the game #A Towel Production # APOC #--- global ammo1 global ammo2 global ammo3 global health global tech_parts global exp global radio_parts ammo1=10 ammo2=0 ammo3=0 health=100 tech_parts=0 exp=0 radio_parts=0 def simpstart(): global ammo global health global tech_parts global radio_parts print "You awake in a haze. A crate,a door and a radio." g1 = raw_input("Which do you choose ") if g1 == "CRATE" or g1 == "Crate" or g1 == "crate": print "There is a pack of ammo,some food and an odd microchip" ammo1=ammo1 + 6 health=health + 10 tech_parts=tech_parts + 1 elif g1 =="DOOR" or g1 == "Door" or g1 == "door": print "You are outside" elif g1 == "RADIO" or g1 == "Radio" or g1 == "radio": print "It's only a few parts" radio_parts=radio_parts+3 g2 = raw_input("So this is NYC.Ten years after.There are a few streets.Go west or north ") if g2 == "WEST" or g2 == "West" or g2 == "west": path2() elif g2 == "NORTH" or g2 == "North" or g2 == "north": def path_1pt1(): print "This is where it all started. Freedom Tower. A biotech firm called Aesthos Biotechnology. Based here." print "I worked there." p1 = raw_input("Go in or stay out ") if p1 == "GO IN" or p1 == "Go in" or p1 == "go in": print health print tech_parts print ammo1 print "This looks familiar" print """Flashback 1 Boss: Hey! You go get sample SV57 from the freezer. Me: Will do sir Lab technician: thanks Me: No problem""" print "Not much in here" elif p1 =="STAY OUT" or p1 == "Stay out" or p1 == "stay out": print "It seems a lot of people died here" print """Flashback 1.2 Test subject: AHHGHWhat the what! Lab technician: God! What is happening? Me: What sample was that? Lab technician: SV57 Me: RUN LIKE HECK! The lab tech was infected Me: All my fault...All my fault""" print """Man: Hello. Me: Who are you. Man:That is...unnecessary at this time. Me: Then why are you here? Man: To help Man: I know where your family is. Me: Where?! Man: Ontario, Canada. That is 282 miles.""" print " Man: This a long journey, but I believe you can accomplish it." print print print "Ontario is north. Got to get there." p2 = raw_input("There is a pack of crawlers up ahead. Attack or sneak ") if p2 == "ATTACK" or p2 == "Attack" or p2 == "attack": print "You attacked the crawlers at the loss of 6 ammo and 19 health, but gained 55 exp" ammo1=ammo1-6 health=health-19 exp=exp+55 elif p2 == "SNEAK" or p2 == "Sneak" or p2 == "sneak": print "You snuck past the crawlers at the gain of 45 exp" exp=exp+45 p3 = raw_input("Gangster: You! What you got?! Attack or run away ") if p3 == "ATTACK" or p3 == "Attack" or p3 == "attack": print "Several of his comrades swarm you. You died." return path_1pt1() health=100 elif p3 == "Run away" or p3 == "RUN AWAY" or p3 == "run away": print "You got away, but you know you made one more enemy today" p4 = raw_input("A car drives up. Do you carjack it or keep walking ") if p4 == "CARJACK" or p4 == "Carjack" or p4 == "carjack": path_1pt3() elif p4 == "Walk" or p4 == "WALK" or p4 == "walk": print "That was a golden opportunity" def path_1pt2(): print "There is a barbed wire topped fence, about 7 feet high. There is a building." print "The weather is picking up, and the wind is getting fast and violent." p5 = raw_input("Stay outside and risk it or check the inside of the building ") if p5 == "Stay" or p5 == "STAY" or p5 == "stay": print "The wind and snow picked up. You got frostbite" return path_1pt1() elif p5 == "CHECK" or p5 == "Check" or p5 == "check": print "There is a group of survivors huddled in a corner" print """Survivor 1: Who are you? Me: Does that matter? Survivor 2: You aren't of 'em Protectors are ya? Me: The what? Survivor 1: They go around killin' people who don't comply with their rules and live in New Quebec" Me:Huh""" exp=exp+200 health=health+50 ammo1=ammo1+29 p6 = raw_input("Do you wish to take a quest or continue the story? ") if p6 == "QUEST" or p6 == "Quest" or p6 == "quest": quest1() elif p6 == "CONTINUE STORY" or p6 == "Continue story" or p6 == "continue story": print "You declined the quest
[Tutor] Help
I get this error Traceback (most recent call last): File "C:\Users\Jack\Desktop\python\g.py", line 56, in path1pt1() NameError: name 'path1pt1' is not defined With this amount of code: def simpstart(): global ammo1 global ammo2 global ammo3 global health global tech_parts global exp global radio_parts ammo1=10 ammo2=0 ammo3=0 health=100 tech_parts=0 exp=0 radio_parts=0 print "You awake in a haze. A crate,a door and a radio." g1 = raw_input("Which do you choose ") if g1 == "CRATE" or g1 == "Crate" or g1 == "crate": print "There is a pack of ammo,some food and an odd microchip" ammo1=ammo1 + 6 health=health + 10 tech_parts=tech_parts + 1 elif g1 =="DOOR" or g1 == "Door" or g1 == "door": print "You are outside" elif g1 == "RADIO" or g1 == "Radio" or g1 == "radio": print "It's only a few parts" radio_parts=radio_parts+3 g2 = raw_input("So this is NYC.Ten years after.There are a few streets.Go west or north ") if g2 == "WEST" or g2 == "West" or g2 == "west": path2_pt1() elif g2 == "NORTH" or g2 == "North" or g2 == "north": path1pt1() def path1pt1(): print "This is where it all started. Freedom Tower. A biotech firm called Aesthos Biotechnology. Based here." print "I worked there."___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] More Help
So I have gotten responses to my previous email sent 3 days ago, all saying define path1pt1() before simpstart, but I do not know how. Help?___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Second follow up
How would I go from one def statement to another? I am developing a text based rpg. Sent from my iPod ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Unknown Cause of Error
I have a slight problem. My program will not open. On top of that, I have written similar programs all to no avail. I am creating a text adventure and want there to be different rooms. Here is my code: def menu(): print "Welcome to Tomb Explorer!" print "A game of Exploration from Bulldog Development" print "Press [1] to Play or [2] to Exit" menu1=raw_input(" >> ") if menu1== "2": quit() if menu1== "1": room1() menu() Thanks A Ton!___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Buttons
Is there a way to make buttons a little like a raw_input in the context when the user presses the button, the program performs a function?___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Py2Exe Problems
I have written a setup.py file to compile a script to a standalone exe. My error is here: Traceback (most recent call last): File "C:\Users\Jack\Desktop\compiler\setup.py", line 4, in setup(console=["te.py"]) File "C:\Python27\lib\distutils\core.py", line 140, in setup raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg SystemExit: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: setup.py --help [cmd1 cmd2 ...] or: setup.py --help-commands or: setup.py cmd --help error: no commands supplied My code is here: from distutils.core import * import py2exe setup(console=["te.py"]) Get back to me asap.. Thanks!___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Compilation Error
1. I compiled a script withpy2exe.I have the .exe ,but when I run it,the window just closes itself.Inthe cmd window fromwhich I compiled the script from,Itsays some dlls are needed.Whatdoes this this have to dowithit,andmore importantly,isthere any solution?___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] PyInstaller
I am using PyInstaller now for building, but I still have a problem! My error is as follows: Traceback (most recent call last): File C:/Users/Jack/Desktop/pyinstaller-pyinstaller-61571d6/PyInstaller/Build.py from PyInstaller.loader import pyi_archive, pyi_carchive ImportError: cannot import name pyi_archive Please help! I am very frustrated with no way to compile my scripts!___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] EXE Problem
I compiled a program in python, but the second I open it, there is a flash of the error, but then the cmd window closes. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Global Variables
Is there a way to keep a global throughout multiple def statements? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] random.choice() problem
I am trying to use random.choice for a text based game. I am using windows 7, 64-bit python. Here is my code: def lvl2(): print "COMMANDER: Who should you train with?" trn=random.choice(1,2) if trn==1: lvl2_1() print "Squad One!" elif trn==2: lvl2_2() print "Squad Nine!" Here is my error: File "C:\Users\Jack\Desktop\python\skye.py", line 20, in lvl2 trn=random.choice(1,2) TypeError: choice() takes exactly 2 arguments (3 given) >>> Thanks!___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Repeat Until Dead
In a combat system, how would I have a certain raw_input repeat until the enemy is dead? Thanks a ton, Jack___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] While problem
I have a small problem with the while function.It prints an odd variable that has nothing to do with the function. It prints "Squad One!". Here is my code for the 3 def's that have something to do with the while function. def tcombat(): c1am=10 c2am=10 enam="Qasi" ehealth=15 edam=random.choice([5,6,7,8,9]) thealth=20 tdam=random.choice([6,7,8,9,10]) enemyalive=True while enemyalive==True: t2=raw_input(">>") if t2.lower=="FIRE CANNON 1": c1am-=c1am-1 ehealth-tdam print "Cannon Fired!" print "Enemy Health=", ehealth elif t2.lower=="FIRE CANNON 2": c2am=c2am-1 ehealth-tdam print "Cannon Fired!" print "Enemy Health=", ehealth print "Good Job!" print "You beat the training dummy." print "Nothing like real combat" print "But screw you, here you go!" print "(Into real combat)" lvl3() def lvl2_2(): print "Squad Nine" print "This team looks veryumm..Dumb." print "There is one guy sitting on a stool" print "he has a star sticker on his chest." print "The other guy is vomiting on his" print "pants." print "BEGIN TRAINING" print "TRAINING: When you are roaming around the skies, you type 'Engage [Ship Name]'" print "TRAINING: While in combat, type 'Fire [Cannon Number (not spelt)]' to fire a cannon at a ship" print "All entries must be in lower caps!" print "TRAINING: There may be consequences for firing upon certain ships." print "--BEGIN TRAINING--" print "There is a ship near yours, the Qasi. It is flying" print "the enemy flag." print "There are 2 cannons on your ship." c1am=10 c2am=10 enam="Qasi" ehealth=15 edam=random.choice([5,6,7,8,9]) thealth=20 tdam=random.choice([6,7,8,9,10]) enemyalive=True if ehealth==0: enemyalive=False t1=raw_input(">>") if t1.lower=="engage qasi": print enam ,"Engaged in Combat" tcombat() def lvl2_1(): print "Squad One" print "This team looks much more able than Squad Nine." print "TYRONE:Hi! I'm Tyrone, he's James, she's Ashley, and that guy over there," print "he's Bob." print "BEGIN TRAINING" print "TRAINING: When you are roaming around the skies, you type 'Engage [Ship Name]'" print "TRAINING: While in combat, type 'Fire [Cannon Number (not spelt)]' to fire a cannon at a ship" print "TRAINING: There may be consequences for firing upon certain ships." print "--BEGIN TRAINING--" print "There is a ship near yours, the Qasi. It is flying" print "the enemy flag." print "There are 2 cannons on your ship." c1am=10 c2am=10 enam="Qasi" ehealth=15 edam=random.choice([5,6,7,8,9]) thealth=20 tdam=random.choice([6,7,8,9,10]) enemyalive=True if ehealth==0: enemyalive=False t1=raw_input(">>") if t1.lower=="ENGAGE QASI": print "Engaged in Combat" tcombat() Thanks!___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] True to False and Other things!
In my game, I am trying to make it so when the enemy's health equals 0, the player advances. I used a while statement and a true or false variable. When the enemy health is less than or equal to 0, the program exits the while statement. It does not work. It keeps going. How could I fix this? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Boosts
In my concept, when the player buys a boost, their karma (a global) is multiplied by 25% when added to. How would I do this? Thanks.___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Error in Game
The player has an option to upgrade or not. I know the code is correct, but it doesn't send the player to the shop. Here is the code: def lvl3_2(): print "You beat level 3!" print "Congratulations!" print "You have liberated the Bristol Channel!" print "[Y] to go to the shop or [N] to advance." final1=raw_input(">>") if final1.lower()=="y": shop2() elif final1.lower()=="n": lvl4() Help?___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Exiting a while
How would I exit a while statement. The while is to keep the player in combat with an enemy until said enemy is dead. I tried using an if, but it just doesn't work. Jack___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Combat Error
When the player of my game fire his/her cannon, it is supposed to get rid of some of the enemy's health. It does not. I have no clue what the error is, so I need help. Here is the Python Shell output: >>fire cannon 1 Fired! Enemy health= 75 They fired at you! Your health is now 55 >>fire cannon 2 Fired! Enemy health= 75 They fired at you! Your health is now 55 >>fire cannon 1 Fired! Enemy health= 75 They fired at you! Your health is now 55 >> Here is the code: def lvl4combat(): print "The barracks are constructed of wood and cobblestone." print "A large, single cannon sits on the top, searching the sky for enemy airships." print "The cannon is manned by a single team of three men." print "The cannon is large and industrial." print "Remember your training." cannonhealth=75 cannondamage=random.choice([10,17,13]) currhealth=health while cannonhealth > 0: print "They fired at you!" currhealth-cannonhealth print "Your health is now",currhealth combat=raw_input(">>") if combat.lower()=="fire cannon 1": print "Fired!" cannonhealth-attack print "Enemy health=",cannonhealth elif combat.lower()=="fire cannon 2": print "Fired!" cannonhealth-attack print "Enemy health=",cannonhealth if currhealth <= 0: break defeat1() if cannonhealth <= 0: break victory1() if kboost==True: karma+25*.25 elif kboost==False: karma+25___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] how to save variables after a user quits in python
I am coding a game and I want the player to be able to quit the game and immediately take off right from where they started from. --Jack___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] SHA256 P2P Chat in python
Sent from my iPhone Begin forwarded message: > From: Jack Little > Date: June 6, 2014 at 6:41:04 PDT > To: "tutor-requ...@python.org" > Subject: SHA256 P2P Chat in python > Reply-To: Jack Little > > Hi Mailing List. > > I was wondering if it is possible to make a p2p chat application with sha256 > secured onion routing in python, and if so, what functions, guides, modules, > etc. would I have to look at. > > > > Thanks ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor