Jul-20-2020, 05:42 PM
Hi I am working on a text based game but I've ran into a slight problem. In the bit where you choose the weapon i use and input but for some reason it takes that input and under my if statment it says your weapon is not defined. If you choose sword as your weapon is says sword is not defined when its not even a variable
from pygame import * import sys,time,os Welcome = 'A Villian: Mwa Ha Ha Ha I have come to rain terror upon your village\n\ ' Welcome2 = 'A Villian: And Who are you\n\ ' Chat = 'Well Well Well ' Chat2 = 'You happen to have caught me on a bad day. Im going to have to kill you\n\ what puny weapon do you have this time a sword? a dagger? a mace?\n\ ' Um = 'I\'\ve never heard of that but I guess thats ok' mixer.init() mixer.music.load('30 Minutes.ogg') mixer.music.play() #while mixer.music.get_busy(): #time.Clock().tick(10) def typewriter(Welcome): for char in Welcome: sys.stdout.write(char) sys.stdout.flush() time.sleep(0.05) def typewriter(Welcome2): for char in Welcome2: sys.stdout.write(char) sys.stdout.flush() time.sleep(0.05) def typewriter(Chat): for char in Chat: sys.stdout.write(char) sys.stdout.flush() time.sleep(0.05) def typewriter(Chat2): for char in Chat2: sys.stdout.write(char) sys.stdout.flush() time.sleep(0.05) def typewriter(Um): for char in Um: sys.stdout.write(char) sys.stdout.flush() time.sleep(0.05) Um=True print('An explosion surrounds you as the wind swirls in your face') time.sleep(1) typewriter(Welcome) print('You: Not today old fool') time.sleep(1) typewriter(Welcome2) Name = input ('I am ') typewriter(Chat) print (Name + '.') typewriter(Chat2) Weapon = input ('I have a ') Weapon = (Weapon.lower()) print (Weapon) if not Weapon == sword: if Um == False: typewrite(Um) if not Weapon == mace: if Um == False: typewrite(Um) if not Weapon == dagger: if Um == False: typewrite(Um)