Edit: Putting dates

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
Headache
Regular
Posts: 101
Joined: Sat Mar 20, 2010 9:29 am
Contact:

Edit: Putting dates

#1 Post by Headache »

EDIT:
Got other Qs answered... somewhat. New Q here. :?

How do I code dates in DSE? (AKA first day is Monday 1, second is Tuesday 2... stuff like that).

EternalDream
Veteran
Posts: 208
Joined: Sat Nov 27, 2010 6:04 pm
Completed: Secret Santa
Projects: Memory Lane
Contact:

Re: Edit: Putting dates

#2 Post by EternalDream »

This is what I can tell you that might help you:



Ren'Py has three default layers. The upper-most layer (closest to the front) is called the "overlay".

def date_overlay():
if show_date:
ui.text(month + "%d" % day, size=20, color="#ffffff")

config.overlay_functions.append(date_overlay)
In the example, "month" is a string of the name of the current month, and "day" is an integer of the current date. The "if show_date" is a way to toggle the date off and on when you don't want it. Make sure you define whether or not "show_date" is True or False before you begin the game.

^ From the RenPy FAQ : http://www.renpy.org/wiki/renpy/FAQ#How ... _screen.3F


Actually, I tried and it didn't work =/ So I would also like this question to be answered...

shylock
Regular
Posts: 35
Joined: Wed Oct 13, 2010 11:57 am
Projects: Isle of St. Marcus, `Silver Seas'
Location: Upstate NY
Contact:

Re: Edit: Putting dates

#3 Post by shylock »

Code: Select all

def date_overlay():
        if show_date:
            ui.text(datestr, size=16, color="#fff", xpos=0.13)
    config.overlay_functions.append(date_overlay)
works just fine for me, where 'datestr' is a string implemented by a separate function. I keep track of the number of days passed and then use a module function to get the day:

Code: Select all

if (divmod(date,7)[1] == 1): 
            datestr = 'Tuesday,'
        elif (divmod(date,7)[1]  == 2):
            datestr = 'Wednesday,'
and so on. every time I increment the day, I call the function that assigns datestr.

Headache
Regular
Posts: 101
Joined: Sat Mar 20, 2010 9:29 am
Contact:

Re: Edit: Putting dates

#4 Post by Headache »

So where do I put this code?

shylock
Regular
Posts: 35
Joined: Wed Oct 13, 2010 11:57 am
Projects: Isle of St. Marcus, `Silver Seas'
Location: Upstate NY
Contact:

Re: Edit: Putting dates

#5 Post by shylock »

I have it in an init python block.

Post Reply

Who is online

Users browsing this forum: No registered users