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.
-
lsf22
- Regular
- Posts: 98
- Joined: Wed Feb 23, 2022 9:43 pm
-
Contact:
#1
Post
by lsf22 » Sun Mar 13, 2022 8:31 am
I feel like I'm missing an understanding about the
elif statement.
For example in one of my flag requirements for scenes, I use multiple "
if" statements because I
only want that scene to activate when the requirements are met and not have the scene triggered otherwise. For example I have the use of multiple "if" statements, but for some reason it seems like I may be misunderstanding "
if" and "
elif".
This is just a made up example:
Code: Select all
if Day1 == True:
jump Monday
if Day2 == True:
jump Tuesday
if Day3 == True:
jump Wednesday
if Day4 == True:
jump Thursday
if Day5 == True:
jump Friday
if Day6 == True:
jump Saturday
if Day7 == True:
jump Sunday
Would it be correct to use that or to only have the first item using the "
if" statement and the rest using "
elif"?
-
Rex Nihilo
- Newbie
- Posts: 4
- Joined: Sat Jan 18, 2020 10:20 am
- Projects: Dig My Way
- Tumblr: nihilorex
- Deviantart: nihilorex
- Github: rex-nihilo
- Location: Third Stone from the Sun
-
Contact:
#2
Post
by Rex Nihilo » Sun Mar 13, 2022 9:13 am
It is correct to use only "if" statements but :
When using "elif", if one condition is satisfied, it would not check the other conditions.
When using "if", all conditions are tested one by one, which can represent a significant performance overhead in a tight loop.
Multiple ifs should be used when it is possible for several ifs to be true simultaneously.
Users browsing this forum: Bing [Bot]