Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Default setting for custom name input characteristics?
#1
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."
Quote
#2
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"])
Quote
#3
Oh my god, thank you! I'm super new to Python so I don't know anything at all, haha. You're a lifesaver.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Input as not default method parameter dan789 4 369 Mar-08-2019, 09:04 PM
Last Post: snippsat

Forum Jump:


Users browsing this thread: 1 Guest(s)