[SOLVED] Easy Question: Changing Words/Phrases in Narration Based on Choices?

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
StValentines
Regular
Posts: 37
Joined: Mon Aug 26, 2019 2:08 am
Projects: St. Valentine's Academy for Magical Girls
Contact:

[SOLVED] Easy Question: Changing Words/Phrases in Narration Based on Choices?

#1 Post by StValentines »

I imagine this is really easy, but I've had trouble finding answers to this. Always leads me to entirely different questions. :P

I have a scene where the player chooses an item from a list. This item will be referenced in the future, so I want to change certain lines based on this. For instance, whether the player chooses the pendant or the book, I want later lines of dialogue or narration to reference the pendant, or the book.

I could use if/else statements and write out multiple versions of each line that includes this item in the future, but that seems extremely inefficient compared to simply setting the item as a variable and calling it into each line that references the item. I'm sure there's a way to do that, but I can't figure out how.

So how do I tell the game to place a previously-defined word into text?
Last edited by StValentines on Tue Sep 10, 2019 2:39 am, edited 1 time in total.

User avatar
78909087
Veteran
Posts: 277
Joined: Sat Aug 16, 2014 2:33 pm
Completed: Dungeons and Don't Do It, Wake Up
Projects: Lethe
IRC Nick: Pacermist
Contact:

Re: Easy Question: Changing Words/Phrases in Narration Based on Choices?

#2 Post by 78909087 »

Hey! Sorry if I'm a bit rusty, I'm returning to Lemma after a long break.
From what I remember, you can set a variable as a word.

Code: Select all

label start:
    $ item = "nothing yet"
    "I go to the shop and wander around."
    "Oh! They have my favourite book. But it's so expensive!"
    "I carry it with me through the shop, stopping in front of a display case."
    "Oh again! That pendant somehow conveniently costs the same amount, and is also pretty!"
    "I can only afford one. Hm."
menu:
    "I want the pendant.":
        $ item = "pendant"
        "It's so shiny."
        jump ____
    "I'll choose the book, after all.":
        $ item = "book"
        "I already love it."
        jump ____
label ____:
    "Now that I'm home, I look at the [item]."
    mc "Oh, my sweet [item], I love you."
I am not friends with the sun.
Image

StValentines
Regular
Posts: 37
Joined: Mon Aug 26, 2019 2:08 am
Projects: St. Valentine's Academy for Magical Girls
Contact:

Re: Easy Question: Changing Words/Phrases in Narration Based on Choices?

#3 Post by StValentines »

Yep, that did it! I knew it would be simple, haha. Thanks so much!

User avatar
78909087
Veteran
Posts: 277
Joined: Sat Aug 16, 2014 2:33 pm
Completed: Dungeons and Don't Do It, Wake Up
Projects: Lethe
IRC Nick: Pacermist
Contact:

Re: [SOLVED] Easy Question: Changing Words/Phrases in Narration Based on Choices?

#4 Post by 78909087 »

No problem :)

If you have any questions you can try to PM me, I'll be doing my best to stay active.
I am not friends with the sun.
Image

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]