[solved]How to change a character's name after reaching

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
sixfingeredfez
Newbie
Posts: 6
Joined: Wed Aug 17, 2016 8:36 am
Tumblr: nonw
Deviantart: none
Github: none
Skype: none
Soundcloud: none
Contact:

[solved]How to change a character's name after reaching

#1 Post by sixfingeredfez » Fri Mar 10, 2017 7:34 pm

I'm sort of new to the whole ren'py thing and basically my problem is I want the main protagonist in my dating sim to refer to people by their last name because they go to school at a militaristic-like school but after reaching a certain level of affection with a character I want an event to pop up where the character asks them to address them by their first name and from that point forward for the rest of the game the PC calls the NPC by their first name.

For example, pretend the NPC is called... John Terrance.
Before reaching the appropriate affection level (say, 20):

player "There's Terrance, I wonder what he's doing up so late at night?"

After reaching 20 points of affection:

player "There's John, I wonder what he's doing up so late at night?"

Is there an easy way to do this? I want the player to be able to do this with five romanceable characters.
Last edited by sixfingeredfez on Fri Mar 10, 2017 9:45 pm, edited 1 time in total.

User avatar
indoneko
Miko-Class Veteran
Posts: 528
Joined: Sat Sep 03, 2016 4:00 am
Contact:

Re: How to change a character's name after reaching an event

#2 Post by indoneko » Fri Mar 10, 2017 8:11 pm

We can easily change the displayed name using a character definition with variable name...

Code: Select all

define j = Character("[hisname]", color="#9660eb")
Though you'll need a function to check affection points while simultaneously update the hisname variable.

Edit : wait... are you asking on how to change the displayed name on the text box, or just the dialogue in it?

Code: Select all

player "There's [hisname],  I wonder what he's doing up so late at night?"
My avatar is courtesy of Mellanthe

sixfingeredfez
Newbie
Posts: 6
Joined: Wed Aug 17, 2016 8:36 am
Tumblr: nonw
Deviantart: none
Github: none
Skype: none
Soundcloud: none
Contact:

Re: How to change a character's name after reaching an event

#3 Post by sixfingeredfez » Fri Mar 10, 2017 8:52 pm

Hmm, not on the textbox, just the dialogue when the main character refers to the romanceable character. The problem I'm having is what function would I need to use to check for affection points and update hisname variable at the same time. I can't seem to get a grasp of how it would work.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: How to change a character's name after reaching an event

#4 Post by trooper6 » Fri Mar 10, 2017 9:29 pm

I can think of a few ways to do this. The way for people who have more basic coding skills and the way for people who have more advanced coding skills. They are basically the same method, but one is simpler.

This is the way for more basic coding skills. You have a variable that represents the person's name. You have a variable that represents the affections points. Whenever you add to a person's affection points you check to see if they've reached the right level. If they have, then you change the name variable. If would look like this:

Code: Select all

default jtpoints = 0
default azpoints = 0
default jtname = "Terrance" 
default azname = "Zinacola" 

define jt = Character("[jtname]", color="#9660eb")
define az = Character("[azname]", color="#9660eb")
define pc = Character("Player", color="#9660eb")

# The game starts here.
label start:
    pc "There's [jtname],  I wonder what he's doing up so late at night? JT Points: [jtpoints]"
    $jtpoints +=1
    if jtpoints >= 2:
        $jtname = "John"
        
    pc "There's [jtname],  I wonder what he's doing up so late at night? JT Points: [jtpoints]"
    $jtpoints +=1
    if jtpoints >= 2:
        $jtname = "John"
        
    pc "There's [jtname],  I wonder what he's doing up so late at night? JT Points: [jtpoints]"
    $jtpoints +=1
    if jtpoints >= 2:
        $jtname = "John"

    pc "There's [jtname],  I wonder what he's doing up so late at night? JT Points: [jtpoints]"
    $jtpoints +=1
    if jtpoints >= 2:
        $jtname = "John"

    pc "There's [azname],  I wonder what he's doing up so late at night? JT Points: [azpoints]"
    $azpoints +=1
    if azpoints >= 2:
        $azname = "Abe"
        
    pc "There's [azname],  I wonder what he's doing up so late at night? JT Points: [azpoints]"
    $azpoints +=1
    if azpoints >= 2:
        $azname = "Abe"
        
    pc "There's [azname],  I wonder what he's doing up so late at night? JT Points: [azpoints]"
    $azpoints +=1
    if azpoints >= 2:
        $azname = "Abe"

    pc "There's [azname],  I wonder what he's doing up so late at night? JT Points: [azpoints]"
    $azpoints +=1
    if azpoints >= 2:
        $azname = "Abe"
        
    return
There is a sleeker, more advanced way to do this. Instead of checking by hand each time you add to the affection points, you create a callback function that checks affection points each time you do a python line (which happens whenever you add to the affection points) and if the level is high enough, change the name. That would look like this:

Code: Select all

default jtpoints = 0
default azpoints = 0
default jtname = "Terrance" 
default azname = "Zinacola" 

define jt = Character("[jtname]", color="#9660eb")
define az = Character("[azname]", color="#9660eb")
define pc = Character("Player", color="#9660eb")


init -1 python:   
    def name_check(): 
        global jtpoints
        global azpoints
        global jtname
        global azname
        try:
            if jtpoints == 2:
                jtname = "John"
            if azpoints == 2:
                azname = "Abe"
        except:
            pass
    config.python_callbacks.append(name_check) 
    

# The game starts here.
label start:
    pc "There's [jtname],  I wonder what he's doing up so late at night? JT Points: [jtpoints]"
    $jtpoints +=1
        
    pc "There's [jtname],  I wonder what he's doing up so late at night? JT Points: [jtpoints]"
    $jtpoints +=1
        
    pc "There's [jtname],  I wonder what he's doing up so late at night? JT Points: [jtpoints]"
    $jtpoints +=1

    pc "There's [jtname],  I wonder what he's doing up so late at night? JT Points: [jtpoints]"
    $jtpoints +=1

    pc "There's [azname],  I wonder what he's doing up so late at night? JT Points: [azpoints]"
    $azpoints +=1
        
    pc "There's [azname],  I wonder what he's doing up so late at night? JT Points: [azpoints]"
    $azpoints +=1
        
    pc "There's [azname],  I wonder what he's doing up so late at night? JT Points: [azpoints]"
    $azpoints +=1

    pc "There's [azname],  I wonder what he's doing up so late at night? JT Points: [azpoints]"
    $azpoints +=1
        
    return
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

sixfingeredfez
Newbie
Posts: 6
Joined: Wed Aug 17, 2016 8:36 am
Tumblr: nonw
Deviantart: none
Github: none
Skype: none
Soundcloud: none
Contact:

Re: How to change a character's name after reaching an event

#5 Post by sixfingeredfez » Fri Mar 10, 2017 9:44 pm

Thank you so much for the help, that was exactly what I was looking for! I'll try to implement it in my game when I get the time but for now I think this post is solved.

Post Reply

Who is online

Users browsing this forum: Google [Bot], _ticlock_