How to change Relation of characters?

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
Nikois
Newbie
Posts: 5
Joined: Tue Dec 18, 2018 5:31 am
Contact:

How to change Relation of characters?

#1 Post by Nikois »

hello, I am a rookie in coding and I usually end up getting help from the forum by searching but this time I can't find code for changing relation with someone. I need help desperately,
I want to let people change relation with characters as they are introduced in story. for Example I have introduced Jake in my Novel, but a player wants "Jake" to be his friend but the default is brother. What code do I use?

its similar to changing name
So I used this but didnt work.
$ name = renpy.input("Please enter your Name")
$ name = name.strip()

Thank you.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: How to change Relation of characters?

#2 Post by Per K Grok »

Nikois wrote: Sun Feb 03, 2019 11:13 am hello, I am a rookie in coding and I usually end up getting help from the forum by searching but this time I can't find code for changing relation with someone. I need help desperately,
I want to let people change relation with characters as they are introduced in story. for Example I have introduced Jake in my Novel, but a player wants "Jake" to be his friend but the default is brother. What code do I use?

its similar to changing name
So I used this but didnt work.
$ name = renpy.input("Please enter your Name")
$ name = name.strip()

Thank you.

You could use an input function, but a problem would be that the player could write any number of things and that would be hard to handle.

A menu would be better. That would limit the answers the player can enter. Something like this

Code: Select all


default jakeRel = "brother"

----
menu:
	"Jake is your ..."
	"brother":
		$ jakeRel = "brother"
	"friend":
		$ jakeRel = "friend"
	"butler":
		$ jakeRel = "butler"
	"arch-enemy":
		$ jakeRel = "arch-enemy"

You can then use the variable jakeRel to change what happens in the game depending on which relationship is chosen.

Code: Select all

if jakeReel == "brother":
     [somethings will happen]
elif jakeReel == "friend":
     [something different will happen]

-----

player "This is Jake, he is my [jakeRel]."


Nikois
Newbie
Posts: 5
Joined: Tue Dec 18, 2018 5:31 am
Contact:

Re: How to change Relation of characters?

#3 Post by Nikois »

Per K Grok wrote: Sun Feb 03, 2019 12:09 pm
Nikois wrote: Sun Feb 03, 2019 11:13 am hello, I am a rookie in coding and I usually end up getting help from the forum by searching but this time I can't find code for changing relation with someone. I need help desperately,
I want to let people change relation with characters as they are introduced in story. for Example I have introduced Jake in my Novel, but a player wants "Jake" to be his friend but the default is brother. What code do I use?

its similar to changing name
So I used this but didnt work.
$ name = renpy.input("Please enter your Name")
$ name = name.strip()

Thank you.

You could use an input function, but a problem would be that the player could write any number of things and that would be hard to handle.

A menu would be better. That would limit the answers the player can enter. Something like this

Code: Select all


default jakeRel = "brother"

----
menu:
	"Jake is your ..."
	"brother":
		$ jakeRel = "brother"
	"friend":
		$ jakeRel = "friend"
	"butler":
		$ jakeRel = "butler"
	"arch-enemy":
		$ jakeRel = "arch-enemy"

You can then use the variable jakeRel to change what happens in the game depending on which relationship is chosen.

Code: Select all

if jakeReel == "brother":
     [somethings will happen]
elif jakeReel == "friend":
     [something different will happen]

-----

player "This is Jake, he is my [jakeRel]."

Its not working for me, I typed what you have shown but it takes me back to tracebacks. I really appreciate your reply but can you please tell me how to do it and where to do it? I also want players to type the relationship they want, not to choose from menus. i am real noob here i hope you understand. thanks for the help

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: How to change Relation of characters?

#4 Post by Per K Grok »

Nikois wrote: Sun Feb 03, 2019 2:18 pm -----
Its not working for me, I typed what you have shown but it takes me back to tracebacks. I really appreciate your reply but can you please tell me how to do it and where to do it? I also want players to type the relationship they want, not to choose from menus. i am real noob here i hope you understand. thanks for the help
Here you have a complete script for a menu solution

Everything in the script.rpy
definition and default before label start

Code: Select all

define J = Character ("John")
default jakeRel = "brother"

# The game starts here.###################################################

label start:
    scene bg placeholder

    menu:
        "Jake is your ..."
        "brother":
            $ jakeRel = "brother"
        "friend":
            $ jakeRel = "friend"
        "butler":
            $ jakeRel = "butler"
        "arch-enemy":
            $ jakeRel = "arch-enemy"


    J "This is Jake. He is my [jakeRel]."

    jump start

and here is one using input
(both solutions only give you the opportunity to chose relationship with Jake over and over again)

Code: Select all


define J = Character ("John")
default jakeRel = "brother"

# The game starts here.###################################################

label start:
    scene bg placeholder

    $ jakeRel = renpy.input("Is Jake you brother or your friend?")
    $ jakeRel = jakeRel.strip()


    J "This is Jake. He is my [jakeRel]."

    jump start

but I would really advice against using an input solution. If you are going to use jakeRel to chose different paths you need to have some control over what the player enters.

My advice to anyone starting to learn a new game engine is to start out with really simple stuff. When you are secure in the basics, you can add new fancier stuff one at a time.

When you want to ask about something that has generated an error message in your game, it is helpful if you copy and paste the error message in your post and the portion of the script where things has gone wrong. For script text it is good to use the code-tags. [_code][_/code] but without the underscore.

Nikois
Newbie
Posts: 5
Joined: Tue Dec 18, 2018 5:31 am
Contact:

Re: How to change Relation of characters?

#5 Post by Nikois »

Per K Grok wrote: Sun Feb 03, 2019 4:56 pm
Nikois wrote: Sun Feb 03, 2019 2:18 pm -----
Its not working for me, I typed what you have shown but it takes me back to tracebacks. I really appreciate your reply but can you please tell me how to do it and where to do it? I also want players to type the relationship they want, not to choose from menus. i am real noob here i hope you understand. thanks for the help
Here you have a complete script for a menu solution

Everything in the script.rpy
definition and default before label start

Code: Select all

define J = Character ("John")
default jakeRel = "brother"

# The game starts here.###################################################

label start:
    scene bg placeholder

    menu:
        "Jake is your ..."
        "brother":
            $ jakeRel = "brother"
        "friend":
            $ jakeRel = "friend"
        "butler":
            $ jakeRel = "butler"
        "arch-enemy":
            $ jakeRel = "arch-enemy"


    J "This is Jake. He is my [jakeRel]."

    jump start

and here is one using input
(both solutions only give you the opportunity to chose relationship with Jake over and over again)

Code: Select all


define J = Character ("John")
default jakeRel = "brother"

# The game starts here.###################################################

label start:
    scene bg placeholder

    $ jakeRel = renpy.input("Is Jake you brother or your friend?")
    $ jakeRel = jakeRel.strip()


    J "This is Jake. He is my [jakeRel]."

    jump start

but I would really advice against using an input solution. If you are going to use jakeRel to chose different paths you need to have some control over what the player enters.

My advice to anyone starting to learn a new game engine is to start out with really simple stuff. When you are secure in the basics, you can add new fancier stuff one at a time.

When you want to ask about something that has generated an error message in your game, it is helpful if you copy and paste the error message in your post and the portion of the script where things has gone wrong. For script text it is good to use the code-tags. [_code][_/code] but without the underscore.
Yeah I will definitely paste errors next time, thank you for the help

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], AWizardWithWords