Remembering order of choice?

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
User avatar
AERenoir
Veteran
Posts: 320
Joined: Fri May 27, 2011 8:23 pm
Contact:

Remembering order of choice?

#1 Post by AERenoir »

Is there a way to remember sequence of choices?
For example I have an activity menu, like this:
1. Eat
2. Do homework
3. Exercise

If I choose 1-2-3, I hope to have a different reaction than if I had chosen in the order of 2-3-1.
Using persistents only checks whether I had done the activity or not, and does not check for the sequence.
Last edited by AERenoir on Sun Sep 22, 2019 3:16 am, edited 1 time in total.

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: Remembering order of choice?

#2 Post by Per K Grok »

AERenoir wrote: Sun Sep 22, 2019 3:08 am Is there a way to remember sequence of choices?
For example I have an activity menu, like this:
1. Eat
2. Do homework
3. Exercise

If I choose 1-2-3, I hope to have a different reaction than if I had chosen in the order of 2-3-1.
Using persistents only checks whether I had done the activity or not, and does not check for the sequence.
You could use a list, adding a '1' to the list when option 1 is picked and so on. The list would the be a record of in which order the options where picked.

User avatar
AERenoir
Veteran
Posts: 320
Joined: Fri May 27, 2011 8:23 pm
Contact:

Re: Remembering order of choice?

#3 Post by AERenoir »

Can you explain how this list work in code? Because I wanted the order of choice to matter in the narrative somehow.

E.g choosing 1-2-3 results in "I feel very productive today", but choosing in the order of 2-3-1 results in sonething like "Because I was hungry, I messed up my honework".

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: Remembering order of choice?

#4 Post by hell_oh_world »

AERenoir wrote: Sun Sep 22, 2019 3:21 am Can you explain how this list work in code? Because I wanted the order of choice to matter in the narrative somehow.

E.g choosing 1-2-3 results in "I feel very productive today", but choosing in the order of 2-3-1 results in sonething like "Because I was hungry, I messed up my honework".
Maybe something like this...

Code: Select all

default choice_order = ""
label start:
	$ choice_order = ""
	menu:
		"choice 1":
			$ choice_order += "1"
		"choice 2":
			$ choice_order += "2"
	if choice_order == "12":
		"Something 1"
	elif choice_order == "21":
		"Something 2"

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: Remembering order of choice?

#5 Post by Per K Grok »

AERenoir wrote: Sun Sep 22, 2019 3:21 am Can you explain how this list work in code? Because I wanted the order of choice to matter in the narrative somehow.

E.g choosing 1-2-3 results in "I feel very productive today", but choosing in the order of 2-3-1 results in sonething like "Because I was hungry, I messed up my honework".

Code: Select all


default order=[]     # create empty list
default eat=0         # variables to run a choice only once
default hwrk=0
default Exs=0


label start:


    menu m1:
        "What do you want to do first?"
        "1. Eat" if eat==0:
            $ order.append(1)             ##  add 1 to list order
            $ eat=1                       ##  stop the option to be shown again
        "2. Do homework" if hwrk==0:
            $ order.append(2)
            $ hwrk=1
        "3. Exercise" if Exs==0:
            $ order.append(3)
            $ Exs=1

    if len(order)<3:                        ## running the menu until all options are chosen
        jump m1


    if order[0]==1:                        ## checking and showing the order from the list
        if order[1]==2:
            "The order was 1, 2, 3."
        else:
            "The order was 1, 3, 2."

    elif order[0]==2:
        if order[1]==1:
            "The order was 2, 1, 3."
        else:
            "The order was 2, 3, 1."

    if order[0]==3:
        if order[1]==1:
            "The order was 3, 1, 2."
        else:
            "The order was 3, 2, 1."

    $ eat=0                                ## reseting the variables and emptying the list    
    $ hwrk=0                               ## to run the process again. Just for testing
    $ Exs=0
    $ order.pop()
    $ order.pop()
    $ order.pop()

    jump m1


User avatar
AERenoir
Veteran
Posts: 320
Joined: Fri May 27, 2011 8:23 pm
Contact:

Re: Remembering order of choice?

#6 Post by AERenoir »

Thanks so much!

Post Reply

Who is online

Users browsing this forum: bloodzy, Majestic-12 [Bot]