Confusing multiflag-dependant if statement

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
ImperialWill
Newbie
Posts: 19
Joined: Wed Jun 29, 2016 4:19 am
Contact:

Confusing multiflag-dependant if statement

#1 Post by ImperialWill »

I'm working on a game that I will not be uploading here as per the Terms of Use policies but I have a really confusing if statement that I can't get to work quite right.

if not CallyRescued:
if not CallyScabbard and not CallyTiara and not CallyQuiver and not CallyCharm:
$ rannum = renpy.random.randint(1,25)
if not CallyScabbard or not CallyTiara or not CallyQuiver or not CallyCharm:
$ rannum = renpy.random.randint(1,15)
else:
$ rannum = renpy.random.randint(1,5)

I've tried to make the chances of finding them easier after finding two of the items but the code still feels weird.

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Confusing multiflag-dependant if statement

#2 Post by namastaii »

What's not working with it?

And try adding an 'elif' to the the if statement before the else line. So it's if: if,elif,else

ImperialWill
Newbie
Posts: 19
Joined: Wed Jun 29, 2016 4:19 am
Contact:

Re: Confusing multiflag-dependant if statement

#3 Post by ImperialWill »

So the "if not w and not x and not y and not z" statement is as it should be to make the odds the worst?

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Confusing multiflag-dependant if statement

#4 Post by namastaii »

Well I don't really understand your game that well since this is all I can see. The syntax is right (aside from the indentation which I assume is how it should be in your project), except 'elif' would work better in this.

What do these variables mean and do?
The first line is saying if not all of these things then random number between these numbers. Which means for this line of code to run, all of these variables must be false.
The second is saying if not this or this or this etc then these random numbers. Which means any one of these variables (at least one) needs to be false for the code to run if the first if statement didn't run.

Then else is last resort.

btw** this question is posted in the wrong section so someone will most likely move it

ImperialWill
Newbie
Posts: 19
Joined: Wed Jun 29, 2016 4:19 am
Contact:

Re: Confusing multiflag-dependant if statement

#5 Post by ImperialWill »

I assumed this section because of other thread titles much like my problem and yes the indentation is correct in the Editra. I was wanting it to be hardest to find the first two items starting out on this section of my game.

I apologize if this is the wrong section, but now that I know for sure that I haven't screwed up, I'm okay now. Thank you namastaii! ^_^

Post Reply

Who is online

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