I was wondering if there is an easy way to have lines of dialogue only display if a variable is set to true. An obvious example would be to skip lines of introduction if this is not the first time the characters have spoken to each other.
I have not had any joy trying to use showif so any ideas would be most welcome.
[Solved] displaying dialogue conditional upon a 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.
-
- Newbie
- Posts: 19
- Joined: Thu Oct 24, 2019 11:28 am
- Contact:
[Solved] displaying dialogue conditional upon a variable
Last edited by thomas_oak on Sun Oct 27, 2019 3:29 pm, edited 1 time in total.
- Chiligoat
- Regular
- Posts: 31
- Joined: Thu Mar 21, 2019 7:42 pm
- Projects: Witches 4 Hire
- Location: Sweden
- Contact:
Re: displaying dialogue conditional upon a variable
You can just add a regular if condition into the script.
Code: Select all
if MetBefore == False:
npc "Halt, stranger!"
pc "Wait, I am no foe!"
else:
npc "Halt"
pc "C'mon, Jeff, it's just me."
#The conversation carries on as normal here, regardless of what the check produced
pc "Night shifts sure are a bummer, huh?"
npc "Tell me about it."
Last edited by Chiligoat on Sun Oct 27, 2019 3:59 pm, edited 1 time in total.
-
- Regular
- Posts: 39
- Joined: Wed Sep 12, 2018 4:11 pm
- Completed: ShSt - Bad Day
- Projects: ShSt - Afterparty, Collings University
- itch: https://gnve.itch.io
- Contact:
Re: displaying dialogue conditional upon a variable
Yes, you can use an if statement and label jump to do that.
or even more simple though not always possible (and maybe not the clearest way to do things):
edit: Chiligoat's way would be best for small changes in text/scenes mine for large changes I guess. Hadn't tried their method. Kinda kicking myself for not trying that...
Code: Select all
python:
if x == True:
renpy.jump('end_two')
else:
renpy.jump('end_one')
Code: Select all
$if x == True: renpy.jump('end_two')
writer "You continue with the story if x == False here."
-
- Newbie
- Posts: 19
- Joined: Thu Oct 24, 2019 11:28 am
- Contact:
Re: displaying dialogue conditional upon a variable
Thank you so much. I feel totally stupid now. I was overthinking it. And of course the else is optional so it can be just a one liner.
Who is online
Users browsing this forum: Google [Bot]