[solved]"Chosen" choices without variable
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.
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.
- mjshi
- Regular
- Posts: 179
- Joined: Wed Mar 13, 2013 9:55 pm
- Completed: MazeSite01, Ponderings of Time
- Contact:
[solved]"Chosen" choices without variable
Just a quick question here--
Can Ren'py remember chosen choices throughout one gameplay (not like persistent, grayed out text choices) without the hassle of assigning individual variables to every single choice branch line?
Can Ren'py remember chosen choices throughout one gameplay (not like persistent, grayed out text choices) without the hassle of assigning individual variables to every single choice branch line?
Last edited by mjshi on Sat Sep 13, 2014 4:48 pm, edited 1 time in total.
- Donmai
- Eileen-Class Veteran
- Posts: 1919
- Joined: Sun Jun 10, 2012 1:45 am
- Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
- Projects: Slumberland
- Location: Brazil
- Contact:
Re: "Chosen" choices without variable
Not sure if that's what you mean, but there's $ renpy.fix_rollback()
http://www.renpy.org/doc/html/save_load ... g-rollback
http://www.renpy.org/doc/html/save_load ... g-rollback
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)
TOIRE NO HANAKO (A Story About Fear)
- mjshi
- Regular
- Posts: 179
- Joined: Wed Mar 13, 2013 9:55 pm
- Completed: MazeSite01, Ponderings of Time
- Contact:
Re: "Chosen" choices without variable
I don't mean blocking rollback, what I mean is something that would usually need
and instead of defining hundreds and hundreds of variables for the various choices that are made, is it possible to configure Ren'py to automatically
Code: Select all
init:
$ choice_1 = False
$ choice_2 = False
menu choice:
"Choose one."
"Choice 1":
if choice_1:
"You have already chosen this..."
"Now, choose again."
else:
$ choice_1 = True
"Great. Now, choose again."
"Choice 2":
if choice_2:
"You have already chosen this..."
"Now, choose again."
else:
$ choice_2 = True
"Great. Now, choose again."
jump choice
remember chosen choices throughout one gameplay (not like persistent, grayed out text choices) without the hassle of assigning individual variables to every single choice branch line
- Donmai
- Eileen-Class Veteran
- Posts: 1919
- Joined: Sun Jun 10, 2012 1:45 am
- Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
- Projects: Slumberland
- Location: Brazil
- Contact:
Re: "Chosen" choices without variable
Me too.mjshi wrote:I don't mean blocking rollback
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)
TOIRE NO HANAKO (A Story About Fear)
- mjshi
- Regular
- Posts: 179
- Joined: Wed Mar 13, 2013 9:55 pm
- Completed: MazeSite01, Ponderings of Time
- Contact:
Re: "Chosen" choices without variable
Wha?Donmai wrote:Me too.mjshi wrote:I don't mean blocking rollback
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: "Chosen" choices without variable
I'm a bit confused as well. Are you planning on looping back to the same menus over and over? Because otherwise you wouldn't need to remember each individual choice. Maybe you could be more descriptive as to how you imagine the choices in your game working?
You might want to look at the code for the game FaceTime which has a looping menu set up.
http://games.renpy.org/game/face-time.shtml
But I'm trying to figure out exactly what you are trying to do and how extensive and why.
For example I would see a difference between a central menu with choices that you keep coming back to over and over, where you want to the player to do each choice only once. (Like Go Fishing, Go Swimming, Eat Lunch) and a situation where you want to track if a person has had specific sorts of interactions with a particular person (Talk, Share Stories, Flirt, etc). The former you could do with a looping menu sort of thing, the latter maybe you'd want relationship points. But either way, I don't see why you'd need to have variables for each possible choice. Often you know what choice they make by where you sent them after the choice. So choice 1 == Go to the beach, choice 2 == Go to the park. If they pick Go to the beach, you jump to the beach scene, if they choose the park you jump to the park scene. If there will never be another opportunity to choose between those option to get to those exact same scenes or if no one is going to say, "Hey I saw you at the beach!"...then you don't need a variable to remember.
So...could you give a concrete and practical example of what exactly you want to accomplish? For example: I want to have a maze where they player chooses which direction to go to over and over. Or whatever.
You might want to look at the code for the game FaceTime which has a looping menu set up.
http://games.renpy.org/game/face-time.shtml
But I'm trying to figure out exactly what you are trying to do and how extensive and why.
For example I would see a difference between a central menu with choices that you keep coming back to over and over, where you want to the player to do each choice only once. (Like Go Fishing, Go Swimming, Eat Lunch) and a situation where you want to track if a person has had specific sorts of interactions with a particular person (Talk, Share Stories, Flirt, etc). The former you could do with a looping menu sort of thing, the latter maybe you'd want relationship points. But either way, I don't see why you'd need to have variables for each possible choice. Often you know what choice they make by where you sent them after the choice. So choice 1 == Go to the beach, choice 2 == Go to the park. If they pick Go to the beach, you jump to the beach scene, if they choose the park you jump to the park scene. If there will never be another opportunity to choose between those option to get to those exact same scenes or if no one is going to say, "Hey I saw you at the beach!"...then you don't need a variable to remember.
So...could you give a concrete and practical example of what exactly you want to accomplish? For example: I want to have a maze where they player chooses which direction to go to over and over. Or whatever.
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
*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
- chocojax
- Miko-Class Veteran
- Posts: 702
- Joined: Sun Oct 25, 2009 11:27 am
- Completed: http://art.jphi.me/projects
- Projects: Umbra, Familiarity, Maleficent Justice
- Organization: spaceNote
- Tumblr: chocojax
- Github: jenniferphi
- Location: California
- Contact:
Re: "Chosen" choices without variable
Uhh, I'm confused too.
Are you talking about:
BRANCH 1: Choice A, Choice B, Choice C
- If choice A was chosen, a tree falls down.
- If choice B was chosen, they go for a swim.
- If choice C was chosen, they drive a car.
BRANCH 2: Choice D, Choice E, Choice F
- If choice D was chosen...
- If choice E was chosen...
- If choice F was chosen...
And basically having variables: choiceA, choiceB, choiceC, choiceD, choiceE, choiceF...?
You can "remember" the choices by basically reusing variables, I guess:
BRANCH 1: Choice A, Choice B, Choice C
...
Set variables choiceA, choiceB, choiceC to false.
BRANCH 2: Choice A, Choice B, Choice C
...
Though, that would only work if you had POINT 1 that diverged to three, then converged back to POINT 2, diverge, converge to POINT 3, etc.
**EDIT: Well, you can kinda do it if you have tons of different paths. They just can't ever come back together at some point.
Let's say in P2-2's D, they go for a picnic, and for P2-2's E, they go for a swim. Right before you get to P3, you can do:
- If D, then...
- If E, then...
And you already know that D/E definitely belonged to P2-2, not P2-1. That's a way to cut out P2-1's two choices from the list of variables. '3'
Are you talking about:
BRANCH 1: Choice A, Choice B, Choice C
- If choice A was chosen, a tree falls down.
- If choice B was chosen, they go for a swim.
- If choice C was chosen, they drive a car.
BRANCH 2: Choice D, Choice E, Choice F
- If choice D was chosen...
- If choice E was chosen...
- If choice F was chosen...
And basically having variables: choiceA, choiceB, choiceC, choiceD, choiceE, choiceF...?
You can "remember" the choices by basically reusing variables, I guess:
BRANCH 1: Choice A, Choice B, Choice C
...
Set variables choiceA, choiceB, choiceC to false.
BRANCH 2: Choice A, Choice B, Choice C
...
Though, that would only work if you had POINT 1 that diverged to three, then converged back to POINT 2, diverge, converge to POINT 3, etc.
**EDIT: Well, you can kinda do it if you have tons of different paths. They just can't ever come back together at some point.
Let's say in P2-2's D, they go for a picnic, and for P2-2's E, they go for a swim. Right before you get to P3, you can do:
- If D, then...
- If E, then...
And you already know that D/E definitely belonged to P2-2, not P2-1. That's a way to cut out P2-1's two choices from the list of variables. '3'
- Attachments
-
- branches2.png
- (8.33 KiB) Not downloaded yet
- mjshi
- Regular
- Posts: 179
- Joined: Wed Mar 13, 2013 9:55 pm
- Completed: MazeSite01, Ponderings of Time
- Contact:
Re: "Chosen" choices without variable
What I was trying to say was something a little bit simpler than that--

Basically, I understand that using variables and setting them to true/false would be the easiest way, but if your game has literally tons of this kind of thing, is there some kind of way to not need to have an init block spanning hundreds of lines of code simply from variable 1... 2... 3... ...200 being set to false?

Basically, I understand that using variables and setting them to true/false would be the easiest way, but if your game has literally tons of this kind of thing, is there some kind of way to not need to have an init block spanning hundreds of lines of code simply from variable 1... 2... 3... ...200 being set to false?
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: "Chosen" choices without variable
That menu looks easily done. Here is one more question I'd want to ask for clarification:
After you exhaust all the options in that menu and continue on, will you ever come back to that menu again?
After you exhaust all the options in that menu and continue on, will you ever come back to that menu again?
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
*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
- mjshi
- Regular
- Posts: 179
- Joined: Wed Mar 13, 2013 9:55 pm
- Completed: MazeSite01, Ponderings of Time
- Contact:
Re: "Chosen" choices without variable
It depends on the player, but probably not. The whole reason the "recap of dialogue 1" thing exists is in case the player forgot something that the character in question had said.
However, with the vast amount of options and such, it would be a pain to define everything.
However, with the vast amount of options and such, it would be a pain to define everything.
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: "Chosen" choices without variable
What you want isn't that difficult assuming you aren't going back to that specific menu again.
If you have 500 menus, each with up to 5 choices, you don't need to need to define 2,500 variables, you just need to define 5 and then reuse them. Here is an example of code that does what I think you want. You just need to reset whatever variables you used back to false when right before you jump out of the menu.
If you have some menu that you plan on going back to for some reason even after the player has been through it before, you could just make the choices for that one special menu unique. Otherwise, reuse.
If you have 500 menus, each with up to 5 choices, you don't need to need to define 2,500 variables, you just need to define 5 and then reuse them. Here is an example of code that does what I think you want. You just need to reset whatever variables you used back to false when right before you jump out of the menu.
If you have some menu that you plan on going back to for some reason even after the player has been through it before, you could just make the choices for that one special menu unique. Otherwise, reuse.
Code: Select all
define d = Character('Detective', color="#c8ffc8")
define t = Character('Tony', color="#c8ffc8")
# The game starts here.
label start:
init:
$ choice1 = False
$ choice2 = False
t "You wanted to ask me something, Detective?"
menu tony1:
"Where were you between 8 and 9pm on the night of the murder?":
if choice1:
t "I already told you. I was visiting my mother in the hospital, you can ask anyone!"
else:
t "I was visiting my mother in the hospital. There were lots of witnesses."
$ choice1 = True
"Is it true that you and Vinnie argued last week about the business?":
if choice2:
t "Look buddy, I already told you that we argued because Vinnie wanted to sell the business. Do you have any other questions?!"
else:
t "Yes we argued. Vinnie wanted to sell the business to our rival for half of its value."
$ choice2 = True
"I have no more questions":
$ choice1 = False
$ choice2 = False
jump tony2
jump tony1
menu tony2:
d "Tony, I need to tell you something..."
"Vinnie was having an affair with your husband.":
if choice1:
t "I don't care how many times you say it, I won't believe Vinnie was having an affair with my husband, they hated each other!"
else:
t "That isn't true! My husband hated Vinnie"
$ choice1 = True
"Vinnie stole all of your business's payroll to pay off his debts.":
if choice2:
t "Look, I already told you the payroll wasn't stolen because I delivered it to the bank myself!"
else:
t "That can't be true. I delivered the payroll to the bank after we closed up shop. I know it was there."
$ choice2 = True
"I have nothing to tell you.":
$ choice1 = False
$ choice2 = False
jump tony3
jump tony2
label tony3:
d "I let Tony leave. I needed to gather more evidence before I talked to him again. Maybe it was time to visit Tony's husband."
returnA 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
*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
- mjshi
- Regular
- Posts: 179
- Joined: Wed Mar 13, 2013 9:55 pm
- Completed: MazeSite01, Ponderings of Time
- Contact:
Re: "Chosen" choices without variable
o.otrooper6 wrote:If you have 500 menus, each with up to 5 choices, you don't need to need to define 2,500 variables, you just need to define 5 and then reuse them. Here is an example of code that does what I think you want. You just need to reset whatever variables you used back to false when right before you jump out of the menu.
You're a genius.
Thank you, problem solved~ no more hundreds of variables, yay xD
by the way: nice mini-story ^.^
Who is online
Users browsing this forum: No registered users

