recall a user previous choice later on the game

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
sousarja
Newbie
Posts: 5
Joined: Mon Aug 05, 2019 8:33 pm
Contact:

recall a user previous choice later on the game

#1 Post by sousarja » Sat Nov 14, 2020 12:02 pm

Hello everyone, first and foremost, respect and thank you to all Developers.
I'm trying to create a VN (by myself) focused on the story itself and soundtrack, since there is no 'ability' or hardware for anything else since I am no developer.

Secondly, I'm trying to find the best option to recall/callback a first or previous choice made by the user that further on the game will have an impact on the story, like a new branch/path or involvement of another character.

I read this here: https://www.renpy.org/wiki/renpy/doc/tu ... er_Choices but I'm unsure if this will be applicable to the new Ren'py version, and also if this will mean that I will always have to add the new bits of code bringing back the entire code-behind due to that first choice.

This is what I have:

Code: Select all

# This is a variable that is True if you have requested her number, and False
# otherwise.
default number = False
And then:

Code: Select all

menu:

    "Ask for the number.":
        jump number

    "Leave it alone.":
        jump alone

label number:

    $ number = True
Finally:

Code: Select all

if number:
    N "...etc..."

    girl ".......?!"
If I want to use that first choice again to develop this branch/path it will no longer allow me since the 'variable' was already called for.

I have read other options, but usually are to gain points or earn money, when using an activity/work or until there are no more choices left available for the user.
My goal is just to keep this branch/path open and use it when I find it essential for the script.

Sorry in advance if this is quite simple, but on the current documentation I did not found an example to apply here.

All the best.

Dr_arell
Regular
Posts: 51
Joined: Sun Feb 23, 2020 11:24 pm
Deviantart: DarellArt
Contact:

Re: recall a user previous choice later on the game

#2 Post by Dr_arell » Sat Nov 14, 2020 1:56 pm

1 first of all why not just using jump number/alone again when you need it, you can use jump outside of the menus, its and independent line.

2 you can also just set the variable to false at the begining of number/alone label

3 anyways heres something i think will be useful for you, that does what you want but it might be a bit more complex.

Code: Select all

label start:	
	
	default path_taken = None
	
	menu:
		"i choose the dark path":
			$ path_taken = "dark_path"
		"i choose the good path":
			$ path_taken = "good_path"		

label dark_path:
	"yasuo, you've taken a dark path"
		
label good_path:
	"you chose the good path"
and whenever you need to refer to the selection done before

Code: Select all


label random_name_for_label:
	if path_taken == "dark_path":
		jump dark_path
	elif path_taken == "good_path":
		jump good_path

Dr_arell
Regular
Posts: 51
Joined: Sun Feb 23, 2020 11:24 pm
Deviantart: DarellArt
Contact:

Re: recall a user previous choice later on the game

#3 Post by Dr_arell » Sat Nov 14, 2020 2:07 pm

in addition you can also execute the state of a variable like this

Code: Select all

default number = False


if number == True:
	jump number
elif number == False:
	jump alone

sousarja
Newbie
Posts: 5
Joined: Mon Aug 05, 2019 8:33 pm
Contact:

Re: recall a user previous choice later on the game

#4 Post by sousarja » Sat Nov 14, 2020 2:34 pm

Dr_arell wrote:
Sat Nov 14, 2020 1:56 pm
1 first of all why not just using jump number/alone again when you need it, you can use jump outside of the menus, its and independent line.

2 you can also just set the variable to false at the begining of number/alone label

3 anyways heres something i think will be useful for you, that does what you want but it might be a bit more complex.

Code: Select all

label start:	
	
	default path_taken = None
	
	menu:
		"i choose the dark path":
			$ path_taken = "dark_path"
		"i choose the good path":
			$ path_taken = "good_path"		

label dark_path:
	"yasuo, you've taken a dark path"
		
label good_path:
	"you chose the good path"
and whenever you need to refer to the selection done before

Code: Select all


label random_name_for_label:
	if path_taken == "dark_path":
		jump dark_path
	elif path_taken == "good_path":
		jump good_path
Hi, and thank you for your time, really appreciate it.
This option that allows me to name any label and recall the previous choice seems to solve it. I can bookmark and create an accurate description to keep track of each possible path.

Code: Select all

default number = False


if number == True:
	jump number
elif number == False:
	jump alone
Using the variable this way will allow me to maintain that path on any label that I use if preceded by the initial choice?
Thanks a lot once again for your insight.

Dr_arell
Regular
Posts: 51
Joined: Sun Feb 23, 2020 11:24 pm
Deviantart: DarellArt
Contact:

Re: recall a user previous choice later on the game

#5 Post by Dr_arell » Sat Nov 14, 2020 4:01 pm

labels are like a tell me where to go thing, so saying "will i be able to maintain that path" is kinda wrong, you can maintain that path if you want to, or you can just jump to another label you choose.

move on, do your normal stuff and when you need to do something that depends on that choice the user made (variable named number), use part of code i gave you.

Code: Select all

if number == True:
	"hello michael how are you, im glad you came instead of jhon"
	"im fine and you"
elif number == False:
	"hello jhon how are you, im glad you came instead of michael"
	"im fine and you"
i suggest you check elaine tutorials on youtube, also look for if statements tutorials on python.

sousarja
Newbie
Posts: 5
Joined: Mon Aug 05, 2019 8:33 pm
Contact:

Re: recall a user previous choice later on the game

#6 Post by sousarja » Sat Nov 14, 2020 6:31 pm

Dr_arell wrote:
Sat Nov 14, 2020 4:01 pm
labels are like a tell me where to go thing, so saying "will i be able to maintain that path" is kinda wrong, you can maintain that path if you want to, or you can just jump to another label you choose.

move on, do your normal stuff and when you need to do something that depends on that choice the user made (variable named number), use part of code i gave you.

i suggest you check elaine tutorials on youtube, also look for if statements tutorials on python.
Will definitely do that and check those videos on youtube as well. Thanks, all the best.

Post Reply

Who is online

Users browsing this forum: anouk