Default setting for custom name input characteristics? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Default setting for custom name input characteristics? (/thread-20357.html) |
Default setting for custom name input characteristics? - beardelune - Aug-06-2019 This is kind of a complicated question, but here goes. I'm trying to make a visual novel with RenPy that has a custom name input feature, and I want certain characteristics (code names and masks, in this case) that will be relevant later on in the game to be defined for SOME custom names, and have a default setting for any OTHER custom names. This is the code I have right now, which works, but if I enter in anything that is outside the defined names (Gabriel, Ume, Umetaro, Priti, Kai, Kahi, or Alexis) it gives me <code_name unbound> and <mask unbound> in the text box (though no error message). I've tried setting the name in the very last block as "", "%(player_name)s", and "[other]", none of which work. Any idea how to set it up so I can make a true default setting? n "The letter reads as follows:" show letter open n "%(player_name)s--" n "You are formally invited to a masquerade party on the night of All Hallow's Eve, October 31, 1923. Enclosed in this box, you will find a mask for your use. You have also been assigned a codename, for the sake of discretion." n "You may use it or not." if player_name == "Gabriel": $ code_name="Loki" $ mask="raven" if player_name == "Ume": $ code_name="Shiva" $ mask="mouse" if player_name == "Umetaro": $ code_name="Shiva" $ mask="mouse" if player_name == "Priti": $ code_name="Aphrodite" $ mask="sparrow" if player_name == "Kai": $ code_name="Mercury" $ mask="racoon" if player_name == "Kahi": $ code_name="Kokopelli" $ mask="frog" if player_name == "Alexis": $ code_name="Hera" $ mask="cat" if player_name == "%(player_name)s": $ code_name="Lachesis" $ mask="python" n "The code name enclosed is %(code_name)s; when you open the box, a beautifully-carved wood-and-gemstone %(mask)s mask is there. It fits you perfectly." RE: Default setting for custom name input characteristics? - fishhook - Aug-07-2019 Just use dictionary characters = { "Ume": {"code_name": "Shiva", "mask": "mouse"}, "Umetaro": {"code_name": "Shiva", "mask": "mouse"}, "Alexis": {"code_name": "Hera", "mask": "elephant"}, } name = "Umetaro" character = characters.get(name) if character is None: print("error") else: print(character["code_name"]) print(character["mask"]) RE: Default setting for custom name input characteristics? - beardelune - Aug-09-2019 Oh my god, thank you! I'm super new to Python so I don't know anything at all, haha. You're a lifesaver. |