Guest User

Untitled

a guest
Jan 22nd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. # give the player the ability to "talk" and touch things
  2.  
  3. # if there is nothing to interact with, say that there is nothing
  4. if "interobj" not in self.location and "interper" not in self.location:
  5. dismiss_fx.play()
  6. print("There's nothing of interest here.")
  7.  
  8. # proceed if there is
  9. else:
  10. # print the things that are in the room
  11. confirm_fx.play()
  12. print("In the area, these things stand out to " + self.name + ": ")
  13. if "interobj" in self.location:
  14. print(colorama.Fore.YELLOW + colorama.Style.BRIGHT + self.location["interobj"])
  15. if "interper" in self.location:
  16. print(colorama.Fore.YELLOW + colorama.Style.BRIGHT + self.location["interper"])
  17.  
  18. # prompt the user to interact with one of the things
  19. interaction = input(colorama.Fore.CYAN + colorama.Style.BRIGHT + "nWhich do you want " + self.name + " to interact with?: ")
  20.  
  21. # determine if the thing the user interacted with is in the location
  22. try:
  23. raise KeyError(interaction)
  24.  
  25. except KeyError as e:
  26. if str(e) != self.location["interobj"]:
  27. raise
  28.  
  29. elif interaction == self.location["interobj"]:
  30. # return whatever was noteworthy about the object
  31. confirm_fx.play()
  32. print(colorama.Fore.YELLOW + colorama.Style.BRIGHT + self.location["intercom"])
  33. print("")
  34.  
  35. checkprog(self,interaction)
  36.  
  37. except KeyError as e:
  38. if str(e) != self.location["interper"]:
  39. raise
  40.  
  41. elif interaction == self.location["interper"]:
  42. # return whatever the character had to say
  43. confirm_fx.play()
  44. print(colorama.Fore.YELLOW + colorama.Style.BRIGHT + self.location["intersay"])
  45. print("")
  46.  
  47. checkprog(self,interaction)
  48.  
  49. except KeyError:
  50. # input is invalid
  51. invalid_fx.play()
  52. print(self.name + " couldn't find a '" + interaction + "'.")
  53. print("")
Add Comment
Please, Sign In to add comment