Create and Fuck your AI Slut -70% OFF
x

Ren'Py Using a nickname dictionary with player selected names

DV FiSTer

Newbie
Game Developer
Jun 12, 2023
50
115
43
I'm having a major issue with getting names to pull properly out of a nicknames dictionary I've established...


It's fine with the names that are just the default, but 5 of my characters you can change their names

Based on whether you activate incest, you'll get incest=True or incest=False, which determines what various characters will call one another...there are 14 characters with varying levels of relationship if incest on, so made a dictionary to make it easier on myself...

Character 'n1' is static named, and everything works fine when calling in her name... characters 'mc' and 'd1' you're able to change the name and give me issues...

In my definitions file: 01_define.rpy I establish default names:

default mc_first = "John"​
default mc_last="Smith"​
default d1_first = "Tally"​
default d1_last = "Frey"​
default n1_first = "Mindy"​
default n1_last = "Phillips"​
default nickname = {​

'mc': {​
'd1':{True: d1_first, False: d1_first},​
'n1":{True: n1_first , False: d1_first},​
},​
'd1': {​
'mc':{True: "Daddy", False: mc_first},​
'n1':{True: n1_first, False: n1_last},​
},​
'n1': {​
'mc':{True: "Uncle" + mc_first, False: mc_first},​
'd1':{True: d1_first, False: d1_first},​
}
}​

***Of course, I have a lot more lines as there are far more than 3 characters involved***

And over in options.rpy I have...

init python:
# nickname call
def nick(speaker, target):
if speaker not in first_name:
return "ERROR: Invalid speaker ID!"
return nickname[speaker][target][incest]​


So, a short time into the script, you get to rename, if you choose, the MC and the other 4 members of his immediate family... here's two of them...

label mc_naming:
$ mc_first = renpy.input("I can't even recall our name...is it?", default="John")
$ mc_first = mc_first.strip()
$ first_name["mc"] = mc_first​

and then

label d1_naming:

$ d1_first = renpy.input ("Her name is...", default="Tally")
$ d1_first = d1_first.strip()
$ first_name["d1"] = d1_first​


n1's name is static....

From this point forward, I can enter (for very basic examples)… We'll assume that "Bob" was chosen for mc and "Jane" for d1 in my examples

d1 “Hi there, I’m [d1_first]”
mc "Hi, [d1_first], I'm [mc_first]"
The game spits out...

Hi there, I'm Jane
Hi, Jane, I'm Bob

This shows that, obviously the game has captured the player entered name.

If, however, I’m having another character speak to d1, I want to use the nickname so they address her properly, so I might enter.[/INDENT]

Easy enough... If d1 is addressing MC and incest = True, there is no problem...

d1 “Hi, [nick(‘d1’,’mc’)”​
returns

"Hi, Daddy"​


The trouble comes with n1...

n1 "Hi, [nick('n1', 'mc')!​

Returns, Hi, Uncle John. *the default name, not the player entered "Bob"

Basically, if it pulls a XXX_first (or XXX_last in some cases) from the dictionary it will use the default name, not the player entered name... if the dictionary has something in quotes ("Daddy", or "Uncle" it's fine, but trying to add the [first_name] after uncle causes the issue...

Likewise, if incest=False, both d1 and n1 would give "John" as the name.

For the time being, I’m using if/else statements
if incest:
n1 “Hi, Uncle [mc_first]"
else:
n1 “Hi, [mc_first]”​

but, as I’m sure you can imagine, that isn’t a goo long-term solution and more than doubles the amount I need to type to get everything done.

I'd also like to add an option for the player to be able to say what they call each other once friendship established, but one thing at a time