So I'm trying to set up a calendar for my game using this calendar here. It works more or less the way I want it to, with time advancement and a day limit that triggers an ending, but I want specifically to call events on Saturdays and Sundays that differ from weekdays. I'm not exactly sure how I can set that up.
This is in my script.rpy:
Code: Select all
init python:
def date_overlay():
if show_date:
ui.text(calendar.string(), xalign=0.7, size=20)
config.overlay_functions.append(date_overlay)
class Calendar(object):
'''Provides time-related information based on a sequence of day names.
Most class methods take a daycount parameter, which is assumed to be a count
of passed days, starting with 1 for the first day.
newmoonday is the daycount of the first new moon, e.g. 1 for the first
day.
Provides date based on different logic (counter).
'''
def __init__(self, day=1, month=1, year=1):
self.day = day
self.month = month
self.year = year
self.days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
self.month_names = ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December']
self.days_count = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
self.mooncycle = 29
self.newmoonday = 1
def string(self):
return "(%s) - %s %d %d"%(self.weekday(), self.month_names[self.month], self.day, self.year)
def next(self):
global day
day = day + 1
self.day += 1
if self.day > self.days_count[self.month]:
self.month += 1
if self.month > 12:
self.month = 1
self.year += 1
self.day = 1
def weekday(self):
'''Returns the name of the current day according to daycount.'''
dayidx = day - 1
daylistidx = dayidx % len(self.days)
return self.days[daylistidx]
Code: Select all
label start:
python:
day = 6
calendar = Calendar(day=20, month=10, year=2017)
show_date = True
$ gday = 0
And this is the code that I want to figure out what day of the week it is & what events to call.
Code: Select all
label daybegin:
$ calendar.next() # For the next day
$ gday += 1
"It's day %(gday)d."
if (gday >= 30):
jump finalday
if day == 1:
jump sundaymorn
elif day == 7:
jump saturdaymorn
else:
jump weekdaymorn
This is my first post & my first real attempt at Renpy use, so please let me know if this needs to go to another forum.