Page 1 of 1

Calendar showing correctly

Posted: Mon Jun 17, 2019 7:10 pm
by richycapy
Hi!

Base on this script:
viewtopic.php?f=8&t=25098

So I modify your script for my game, since it has some features I dont requiere, and I needed time of the day, so I have this:

Code: Select all

init python:
    class Calendar(object):
        def __init__(self, week=1, timeofdaycounter=0):
            self.week = week
            self.timeofdaycounter = timeofdaycounter
            self.daycount_from_gamestart = 0
            self.days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
            self.timeofdayname = ["Morning", "Noon", "Afternoon", "Evening", "Night"]

        @property
        def game_day(self):
            return self.daycount_from_gamestart + 1

        def dayname(self):
            daylistidx = self.daycount_from_gamestart % len(self.days)
            return self.days[daylistidx]

        def timeofday(self):
            return self.timeofdayname[self.timeofdaycounter]

        def nexttime(self):
            if self.timeofdaycounter < 4:
                self.timeofdaycounter += 1
            else:
                self.timeofdaycounter = 0

        def nextday(self, days=1):
            self.daycount_from_gamestart += days
            self.timeofdaycounter = 0

screen calendar:
    modal True
    zorder 100
    vbox:
        align(1.0, 0)
        spacing 10
        text ("Day: [calendar.game_day]")
        text ("Day name: [calendar.dayname]")
        text ("Time of day: [calendar.timeofday]")

label start:
$ calendar = Calendar(1, 0)

    show screen calendar
    call screen room

I get this:
Image

Its shows the count day correctly but the other two shows weird text...

Can you help me?

I want to have the calendar showing the whole time, but hide it when characters are talking

Thanks! :D

Re: Calendar showing correctly

Posted: Mon Jun 17, 2019 8:02 pm
by Remix
Looks like you need to add
@property
just before the two methods in question

Re: Calendar showing correctly

Posted: Mon Jun 17, 2019 8:20 pm
by richycapy
Remix wrote:
Mon Jun 17, 2019 8:02 pm
Looks like you need to add
@property
just before the two methods in question
Awesome!!! Thanks for the help!!