[Tutor] Here is code, no link for my previous question

Oscar Benjamin oscar.j.benjamin at gmail.com
Mon Jan 7 03:21:02 CET 2013


On 7 January 2013 02:07, Jack Little <jacklittlemc at yahoo.com> wrote:
> Here is the code, my error is below the code in itallics

No explanation?

>
> #This is not free source
> #Don't cheat by looking at this
> #If you do you ruin the game

I was a little concerned when I read this part. I guess it's okay for
me to read on...

> #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: AHHGH....What 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"
>       print
>       print """Man: Hello
>                  Me: Hello
>                  Man: I hear you must make it to New Quebec
>                  Me: Yes
>                  Man: Give me 15 exp and you will teleport there."""
>   p7 = raw_input("Teleport or continue  ")
>   if p7 == "TELEPORT" or p7 == "Teleport" or p7 == "teleport":
>           path_1pt3()
>           exp=exp-15
>   elif p7 == "CONTINUE" or p7 == "Continue" or p7 == "continue":
>         print "You chose to continue your route to New Quebec"
>         print """Survivor 1:Here, take these
>                  *He passes car keys*
>                  Me: Thanks
>                  Survivor 1: No problem.
>                  Survivor 2: Just fill up the gas tank"""
>   p8 = raw_input("You can either pick up a map or a compass  ")
>   if p8 == "MAP" or p8 == "Map" or p8 == "map":
>       print "The map has a special square for gas stations"
>       print "It says go west 2 miles"
>   elif p8 == "COMPASS" or p8 == "Compass" or p8 == "compass":
>       print "This seems like it will be impossible to find the gas tank"
>       d1()
>   p9 = raw_input("Go east or west  ")
>   if p9 == "EAST" or p9 == "east" or p9 == "East":
>     def GasStation():
>       global ammo1
>       global ammo2
>       global ammo3
>       global health
>       global tech_parts
>       global exp
>       global radio_parts
>       print "There seems to be a group of marauders gaurding the last tank"
>       p10=raw_input("Approach kindly or attack")
>       if p10.lower== "approach kindly":
>           print """Me: Hey Guys!
>                    Leader:Scram!
>                    Me: Look, I have to find my wife and kids
>                    Leader: I don't care!
>                    Me: I just need that gas tank
>                    Leader: What's in it for me?
>                    Me: Uhhhh.. ammunition
>                    Leader: Sure."""
>           ammo1=ammo1-6
>       else:
>         print"They murdered you!"
>         return GasStation()
>         ammo1=ammo1-6
> else:

I guess this is line 179. As the error says, "return outside
function". A return statement is meaningless outside a function.

>   return path1_pt2()
>   "A snowstorm swept through, killing you."
>
>
> Here is the error:
>
> There's an error in your program:
> ***'return' outside function(g.py,line 179)


Oscar


More information about the Tutor mailing list