Flag Help

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
Mikomi
Veteran
Posts: 324
Joined: Tue Jun 24, 2014 11:45 pm
Completed: That Which Binds Us, Enamored Risks, Alice in Stardom
Projects: Asterism, Magicanna
Organization: Crystal Game Works
itch: CrystalGameWorks
Contact:

Flag Help

#1 Post by Mikomi » Tue Jun 24, 2014 11:54 pm

Hello, I'm kinda new to Ren'Py, and was wondering how I would make flags that would react to certain choices. So far I have 4 choices, and I'd like to be able to make flags for each separate choice. Would I just call it flag1 if I wanted to make it about choice1?

User avatar
ArachneJericho
Regular
Posts: 196
Joined: Sun Jun 22, 2014 2:04 am
Projects: Kaguya Hime
Tumblr: mousedeerproductions
Location: Seattle, WA, USA
Contact:

Re: Flag Help

#2 Post by ArachneJericho » Wed Jun 25, 2014 3:19 am

Code: Select all

$ flag = value
I suggest naming "flag" to be something meaningful. Also remember that flags are just variables, and can have values other than True or False. Here's some sample code:

Code: Select all

menu: 
    "You choose a banana.":
        "That banana looks quite nicely yellow and ripe. Delicious!"
        $ fruit_choice = 'banana'

    "You choose an apple.":
        "That apple turned out to be crisp and scrumptious."
        $ fruit_choice = 'apple'

    "You choose no fruit.":
        "You aren't hungry anyways."
        $ fruit_choice = None

if fruit_choice == 'banana': 
   "You drop your peel on the floor. And then slip on it in a moment."
else if fruit_choice == 'apple':
   "You toss your core on the floor. And then it rolls under your foot and trips you."
else:
   "No fruit chosen, no mess to tidy up! You walk down the hallway without incident."
Hope this helps.

User avatar
Mikomi
Veteran
Posts: 324
Joined: Tue Jun 24, 2014 11:45 pm
Completed: That Which Binds Us, Enamored Risks, Alice in Stardom
Projects: Asterism, Magicanna
Organization: Crystal Game Works
itch: CrystalGameWorks
Contact:

Re: Flag Help

#3 Post by Mikomi » Wed Jun 25, 2014 7:19 pm

ArachneJericho wrote:

Code: Select all

$ flag = value
I suggest naming "flag" to be something meaningful. Also remember that flags are just variables, and can have values other than True or False. Here's some sample code:

Code: Select all

menu: 
    "You choose a banana.":
        "That banana looks quite nicely yellow and ripe. Delicious!"
        $ fruit_choice = 'banana'

    "You choose an apple.":
        "That apple turned out to be crisp and scrumptious."
        $ fruit_choice = 'apple'

    "You choose no fruit.":
        "You aren't hungry anyways."
        $ fruit_choice = None

if fruit_choice == 'banana': 
   "You drop your peel on the floor. And then slip on it in a moment."
else if fruit_choice == 'apple':
   "You toss your core on the floor. And then it rolls under your foot and trips you."
else:
   "No fruit chosen, no mess to tidy up! You walk down the hallway without incident."
Hope this helps.
I think it does- So all I have to do is insert the small line $ flag == value somewhere and then I can enter in different variables for the flags? Also, is there anywhere specific I should put that line?

Thank you for your help!

User avatar
Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Flag Help

#4 Post by Asceai » Wed Jun 25, 2014 7:27 pm

Mikomi wrote:I think it does- So all I have to do is insert the small line $ flag == value somewhere and then I can enter in different variables for the flags? Also, is there anywhere specific I should put that line?

Thank you for your help!
= for assignment (setting a variable to something)
== for comparison (checking a variable is equal to something

Code: Select all

$flag = value

Code: Select all

if flag == True:
  "the flag is set"

User avatar
Mikomi
Veteran
Posts: 324
Joined: Tue Jun 24, 2014 11:45 pm
Completed: That Which Binds Us, Enamored Risks, Alice in Stardom
Projects: Asterism, Magicanna
Organization: Crystal Game Works
itch: CrystalGameWorks
Contact:

Re: Flag Help

#5 Post by Mikomi » Wed Jun 25, 2014 9:41 pm

Asceai wrote:
Mikomi wrote:I think it does- So all I have to do is insert the small line $ flag == value somewhere and then I can enter in different variables for the flags? Also, is there anywhere specific I should put that line?

Thank you for your help!
= for assignment (setting a variable to something)
== for comparison (checking a variable is equal to something

Code: Select all

$flag = value

Code: Select all

if flag == True:
  "the flag is set"
I understand they're two different things, but I don't understand what they mean.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], nyeowmi