[Solved] displaying dialogue conditional upon a variable

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
thomas_oak
Newbie
Posts: 19
Joined: Thu Oct 24, 2019 11:28 am
Contact:

[Solved] displaying dialogue conditional upon a variable

#1 Post by thomas_oak »

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.
Last edited by thomas_oak on Sun Oct 27, 2019 3:29 pm, edited 1 time in total.

User avatar
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

#2 Post by Chiligoat »

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.

GNVE
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

#3 Post by GNVE »

Yes, you can use an if statement and label jump to do that.

Code: Select all

python:
    if x == True:
        renpy.jump('end_two')
    else:
        renpy.jump('end_one')
or even more simple though not always possible (and maybe not the clearest way to do things):

Code: Select all

	$if x == True: renpy.jump('end_two')
	
	writer "You continue with the story if x == False here."
	
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... :roll:

thomas_oak
Newbie
Posts: 19
Joined: Thu Oct 24, 2019 11:28 am
Contact:

Re: displaying dialogue conditional upon a variable

#4 Post by thomas_oak »

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.

Post Reply

Who is online

Users browsing this forum: Google [Bot]