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.
okay, at the risk of spoiling some of the surprise on one of my secret projects, I have a few questions that involve dates, overlays, and date calculations:
1) [answered] what script would I need to use to display a date (not necessarily a real-world (month/day/year) date, but a date nonetheless) at a specific part of the screen (for instance, the top-right corner)?
2) [answered] what python scripting would be the equivalent for this pseudocode?
This is a straight transliteration of your pseudocode. Personally, I woudln't use globals in GetCurrentDate, but this might be easier depending on the rest of your code. Also I havn't checked the algorithm!
CurrentDay = 1 #initialize this to one
DisplayDay = 1
DisplayMonth = "January" #day 1 == month 1 or "January"
DisplayYear = 1 #see above
Weekday = "Sunday" # day 1 = sunday - using 7-day week
def GetCurrentDate():
global DisplayDay
global DisplayMonth
global Weekday
global DisplayYear
DisplayDay = CurrentDay % 35
DisplayMonth = GetMonth(CurrentDay / 35)
Weekday = GetDayOfWeek(CurrentDay)
DisplayYear = (CurrentDay / 140) + 1
def GetDayOfWeek(temp1):
case = temp1 % 7
if case == 0:
return "saturday"
elif case == 1:
return "sunday"
elif case == 2:
return "monday"
# continue like this for case == 2 ~ case == 6
def GetMonth(temp1):
case = temp1 % 12
if case == 0:
return "January"
elif case == 1:
return "February"
# repeat for case == 1 ~ case == 11
So everytime you want the date to be shown put values for day, month and year variable (make sure they are string not integers) and show date=True. For example:
"Today is January 20, 2009"
$ day='20'
$ month='1'
$ year='2008'
$ show_date=True
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.
It took a bit of playing with it, but I got it to work right (thank god I can actually figure out what's going on with the error.txt/traceback.txt files - that actually helps a lot)
the script I ended up with, in case anyone's interested:
after some more thorough testing, the functionality is there.
the only other thing I would like is to set a background (be it a window or a frame or whatever) for the area occupied by the date so that if I have a bright background with a near-white spot in the top right, the date doesn't "disappear" into the background.
# Control the date and date calculations with regards to the game.
init:
Show_Date = None
CurrentDay = 1 #initialize this to one
DisplayDay = 1
DisplayMonth = "January" #day 1 == month 1 or "January"
DisplayYear = 1 #see above
Weekday = "Sunday" # day 1 = sunday - using 7-day week
python:
def GetDayOfWeek(temp1):
# numbers: 7 = days in week
case = temp1 % 7
if case == 0:
return "Saturday"
elif case == 1:
return "Sunday"
elif case == 2:
return "Monday"
elif case == 3:
return "Tuesday"
elif case == 4:
return "Wednesday"
elif case == 5:
return "Thursday"
elif case == 6:
return "Friday"
def GetMonth(temp1):
# numbers: 35 - days in month
case = (temp1 / 35) % 4
if case == 0:
return "Spring"
elif case == 1:
return "Summer"
elif case == 2:
return "Autumn"
elif case == 3:
return "Winter"
def GetDay(temp1):
# numbers: 35 = days in month
return ((temp1 - 1) % 35) + 1 # subtract one (bugfix - prevent "0" results), then add one to the result.
def GetYear(temp1):
# numbers: 140 = days in year - four months
return (temp1 / 140) + 1
# stuff for display
def date_show():
if not show_date:
return
ui.frame(xpos=1.0, ypos=0.0,xanchor=1.0) #Here's the change
ui.text("%s, %s %d, %d" % (Weekday, DisplayMonth, DisplayDay, DisplayYear) )
config.overlay_functions.append(date_show)
label Refresh_Day:
# ALWAYS CALL THIS LABEL. always.
$ DisplayDay = GetDay(CurrentDay)
$ DisplayMonth = GetMonth(CurrentDay)
$ Weekday = GetDayOfWeek(CurrentDay)
$ DisplayYear = GetYear(CurrentDay)
$ show_date = true
return
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.