What's the correct syntax for this?

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
mystique
Regular
Posts: 43
Joined: Sun Dec 28, 2014 3:19 am
Contact:

What's the correct syntax for this?

#1 Post by mystique » Wed Feb 04, 2015 11:28 pm

Code: Select all

screen calendar2:
    tag menu3
    
    python: 
        if weekday == 1:
            {
                weekday_img = "day_monday.png"
                if phase == 1:
                {
                    phase_img = "day_logo1.png"
                }
                else if phase == 2:
                {
                    phase_img = "day_logo2.png"
                }
                else if phase == 3:
                {
                    phase_img = "day_logo3.png"
                }
            }
        else if weekday == 2:
            {
                weekday_img = "day_tuesday.png"
                if phase == 1:
                {
                    phase_img = "day_logo1.png"
                }
                else if phase == 2:
                {
                    phase_img = "day_logo2.png"
                }
                else if phase == 3:
                {
                    phase_img = "day_logo3.png"
                }
            }
            
        else if weekday == 3:
            {
                weekday_img = "day_wednesday.png"
                if phase == 1:
                {
                    phase_img = "day_logo1.png"
                }
                else if phase == 2:
                {
                    phase_img = "day_logo2.png"
                }
                else if phase == 3:
                {
                    phase_img = "day_logo3.png"
                }
            }
        else if weekday == 4:
            {
                weekday_img = "day_thursday.png"
                if phase == 1:
                {
                    phase_img = "day_logo1.png"
                }
                else if phase == 2:
                {
                    phase_img = "day_logo2.png"
                }
                else if phase == 3:
                {
                    phase_img = "day_logo3.png"
                }
            }
        else if weekday == 5:
            {
                weekday_img = "day_friday.png"
                if phase == 1:
                {
                    phase_img = "day_logo1.png"
                }
                else if phase == 2:
                {
                    phase_img = "day_logo2.png"
                }
                else if phase == 3:
                {
                    phase_img = "day_logo3.png"
                }
            }
        else if weekday == 6:
            {
                weekday_img = "day_saturday.png"
                if phase == 1:
                {
                    phase_img = "day_logo1.png"
                }
                else if phase == 2:
                {
                    phase_img = "day_logo2.png"
                }
                else if phase == 3:
                {
                    phase_img = "day_logo3.png"
                }
            }
        else if weekday == 7:
            {
                weekday_img = "day_sunday.png"
                if phase == 1:
                {
                    phase_img = "day_logo1.png"
                }
                else if phase == 2:
                {
                    phase_img = "day_logo2.png"
                }
                else if phase == 3:
                {
                    phase_img = "day_logo3.png"
                }
            }
            
    add weekday_img align(0.01, 0.01)
    add phase_img align (0.09, 0.01)
The error says:
weekday_img = "day_monday.png" is an invalid syntax

philat
Eileen-Class Veteran
Posts: 1853
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: What's the correct syntax for this?

#2 Post by philat » Wed Feb 04, 2015 11:54 pm

It looks like you're looking for ConditionSwitch. http://lemmasoft.renai.us/forums/viewto ... 51&t=19063

RangerDanger
Regular
Posts: 45
Joined: Wed Jun 27, 2012 11:36 pm
Contact:

Re: What's the correct syntax for this?

#3 Post by RangerDanger » Thu Feb 05, 2015 1:30 am

-----------------------------------------
Last edited by RangerDanger on Thu May 12, 2016 11:49 pm, edited 1 time in total.

User avatar
mystique
Regular
Posts: 43
Joined: Sun Dec 28, 2014 3:19 am
Contact:

Re: What's the correct syntax for this?

#4 Post by mystique » Thu Feb 05, 2015 1:54 am

ConditionSwitch works like a charm! Much more efficient and lesser codes than using the one-by-one if else. Thanks so much, Philat!
To RangerDanger, thanks for your suggestion! I'll do that next time if ever I come up with this problem again.

Post Reply

Who is online

Users browsing this forum: No registered users