Set Condition Using Range of Values

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
Wataru2
Newbie
Posts: 12
Joined: Sat Sep 29, 2018 11:04 am
Contact:

Set Condition Using Range of Values

#1 Post by Wataru2 »

I'm having a hard time figuring out how to get a range of values to use as a condition pass.

Code: Select all

    $ currenttime = hour
    if currenttime = range (8,10):
        show black
Problem is I can't find a syntax that checks whether currenttime is simply in the range of the two numbers...

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Set Condition Using Range of Values

#2 Post by Per K Grok »

Wataru2 wrote: Tue Oct 02, 2018 9:24 pm I'm having a hard time figuring out how to get a range of values to use as a condition pass.

Code: Select all

    $ currenttime = hour
    if currenttime = range (8,10):
        show black
Problem is I can't find a syntax that checks whether currenttime is simply in the range of the two numbers...
You could do

if currenttime >= 8 and currenttime <= 10

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: Set Condition Using Range of Values

#3 Post by IrinaLazareva »

Wataru2 wrote: Tue Oct 02, 2018 9:24 pm Problem is I can't find a syntax that checks whether currenttime is simply in the range of the two numbers...

Code: Select all

    if currenttime in range(8, 11):
        show black
is equivalent to:

Code: Select all

    if 8 <= currenttime < 11:
or

Code: Select all

    if 8 <= currenttime <= 10:

Wataru2
Newbie
Posts: 12
Joined: Sat Sep 29, 2018 11:04 am
Contact:

Re: Set Condition Using Range of Values

#4 Post by Wataru2 »

Thanks! Either of those did the trick! I knew I was messing up with something that's so obvious...

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Semrush [Bot]