calendar text style from class

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
wyverngem
Miko-Class Veteran
Posts: 539
Joined: Mon Oct 03, 2011 7:27 pm
Completed: Simple as Snow, Lady Luck's Due,
Projects: Aether Skies, Of the Waterfall
Tumblr: casting-dreams
itch: castingdreams
Location: USA
Contact:

calendar text style from class

#1 Post by wyverngem » Sat Dec 16, 2017 12:52 pm

I'm working on a simple calendar that's formation starts with a range() and a grid. So far I have set it up so that if i == day i sets it to a specific color.

Code: Select all

grid 7 4:
    for i in range(1, 29):
        frame xmaximum 75 ymaximum 75:
            if i == 3: #This is a placeholder for the event on Spring 3rd. Right now it's always pink despite the event month.
                text str(i) xalign 0.5 yalign 0.5 color "#FF1493"
            elif i == day:
                text str(i) xalign 0.5 yalign 0.5 color "#FF1493" #If today is the i listed, make it pink
            elif i < day:
            	text str(i) xalign 0.5 yalign 0.5 color "#D8BFD8" #Grey it out if the day has passed.              
            else:
                text str(i) xalign 0.5 yalign #Else keep it a plan color
However, if i in range is equal to the day in SEvent and it's displaying the correct month, I want it to style the color differently. How do I write this? I've tried several ways and I can't seem to get it to work. Here's my class.

Code: Select all

init python:
    import renpy.store as store
    class SEvent(store.object):
        def __init__(self, name, month, day):
            self.name = name
            self.month = month
            self.day = day
            event_list.insert(0, self)

    def add_event(name, month, day):
        events = SEvent(name, month, day)
Sample of the python working script.

Code: Select all

    $ event_list = []
    $ add_event("Birthday", "Spring", 3)
Would it just be easier to set up a function that changes the color instead of using if statements within the screen?

User avatar
Zetsubou
Veteran
Posts: 475
Joined: Wed Mar 05, 2014 1:00 am
Completed: See my signature
Github: koroshiya
itch: zetsuboushita
Contact:

Re: calendar text style from class

#2 Post by Zetsubou » Sat Dec 16, 2017 6:58 pm

Write a function which iterates event_list. Check each object in the list for those two fields (month and day).
If they match, have the function return the object. If not, have it return False.
Run this function and assign the return value to a variable at the start of your if..else block.
Add a check to your if..else block for this variable. If the variable is false, there's no event. Else, there is an event, and you can grab the name from the object.
Finished games
-My games: Sickness, Wander No More, Max Massacre, Humanity Must Perish, Tomboys Need Love Too, Sable's Grimoire
-Commissions: No One But You, Written In The Sky, Diamond Rose, To Libertad, Catch Canvas, Love Ribbon, Happy Campers, Wolf Tails

Working on:
Circadian Loop, My Heart Grows Fonder + VN writing commissions

Image

User avatar
wyverngem
Miko-Class Veteran
Posts: 539
Joined: Mon Oct 03, 2011 7:27 pm
Completed: Simple as Snow, Lady Luck's Due,
Projects: Aether Skies, Of the Waterfall
Tumblr: casting-dreams
itch: castingdreams
Location: USA
Contact:

Re: calendar text style from class

#3 Post by wyverngem » Mon Dec 18, 2017 9:21 am

Thanks! I think I get it. :D

Post Reply

Who is online

Users browsing this forum: No registered users