Having display time issues.

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
Trafagal
Regular
Posts: 100
Joined: Mon Apr 29, 2019 9:32 am
Contact:

Having display time issues.

#1 Post by Trafagal »

Hi,

I tried to create a clock, but the output seems to be only a variable. May I ask if anyone of you have an idea how I can make the clock appear?

Thank you in advance!
output.JPG
This is my code:

Code: Select all

label start:
    call variables
    $ GameRunning = True
    while GameRunning:
        $ Output = WeekDays[Days] + " " + Months[Month] + " " + str(Day+1) + " " + str(Hours) + ":" + str(Minutes) "[Output]"
        
    $ Minutes += 30
    if Minutes > 30:
        $ Minutes = 0
        $ Hours += 1
    if Hours > 23:
        $ Hours = 0
        $ Day += 1
        $ Days += 1
    if Day > 6:
        $ Day = 0
    if Days > MonthDays[Month]:
        $ Month += 1
        $ Days = 0
    if Month > 11:
        $ Month = 0
    
    return
    
label variables:
    $ WeekDays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
    $ Months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
    $ MonthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
    $ Minutes = 0
    $ Hours = 12
    $ Days = 0
    $ Day = 0

Check out some of my stuffs here:https://linktr.ee/theartofjoshlab

Art Portfolio: https://www.instagram.com/theartofjoshlab/

Working on a personal Visual Novel~

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: Having display time issues.

#2 Post by hell_oh_world »

better if youll share the screen definition where this output is displayed. also isn't this code...

Code: Select all

    while GameRunning:
        $ Output = WeekDays[Days] + " " + Months[Month] + " " + str(Day+1) + " " + str(Hours) + ":" + str(Minutes) "[Output]"
an infinite loop? i suggest fixing that, that will cause Ren'Py to hang, since `GameRunning == True` is forever equals to that.

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Having display time issues.

#3 Post by gas »

It's Xmas! So, more than requested.

Code: Select all

init python:
    from datetime import datetime, timedelta
    
    def proceed(what):
        today =today +timedelta(minutes = what)
        timestring = today.strformat("%A %B %d %H:%M")
        
default today = datetime(2020, 12, 25, 8, 30)
default timestring = None

label start:
    # initialize, to assign a value to 'timestring'
    $ proceed(0)
    jump loop

label loop:
    show screen clock
    $ proceed(30)
    "Next moment..."
    jump loop

screen clock():
    text "[timestring]"
Datetime is the python module to handle a real date (so after Jan 31 Monday it come Feb 1 Tuesday automatically). It simplify the thing a lot, add many tricks and I'll suggest you to shift to this.
Today is the starting date, in the format year, month, day, hour, minute.
The function 'proceed' add x minutes.
The strformat method create a string the way you want with date objects parameters into that string, using a special code - for example %A is the full weekday name. You can find strftime string convention around the web. The string can be everything, so for example
string = today.strftime("Shortly, today is %a , a really bad day.")
%a become 'Mon', 'Tue' and whatever.
The screen simply render the variable.

IF by any chance you'll see that some screen doesn't render your interpolations, try a double passage.

Code: Select all

screen blob():
    $ da_text = my_text[0]
    text "[da_text]"
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
Trafagal
Regular
Posts: 100
Joined: Mon Apr 29, 2019 9:32 am
Contact:

Re: Having display time issues.

#4 Post by Trafagal »

gas wrote: Fri Dec 25, 2020 9:58 am It's Xmas! So, more than requested.

Code: Select all

init python:
    from datetime import datetime, timedelta
    
    def proceed(what):
        today =today +timedelta(minutes = what)
        timestring = today.strformat("%A %B %d %H:%M")
        
default today = datetime(2020, 12, 25, 8, 30)
default timestring = None

label start:
    # initialize, to assign a value to 'timestring'
    $ proceed(0)
    jump loop

label loop:
    show screen clock
    $ proceed(30)
    "Next moment..."
    jump loop

screen clock():
    text "[timestring]"
Datetime is the python module to handle a real date (so after Jan 31 Monday it come Feb 1 Tuesday automatically). It simplify the thing a lot, add many tricks and I'll suggest you to shift to this.
Today is the starting date, in the format year, month, day, hour, minute.
The function 'proceed' add x minutes.
The strformat method create a string the way you want with date objects parameters into that string, using a special code - for example %A is the full weekday name. You can find strftime string convention around the web. The string can be everything, so for example
string = today.strftime("Shortly, today is %a , a really bad day.")
%a become 'Mon', 'Tue' and whatever.
The screen simply render the variable.

IF by any chance you'll see that some screen doesn't render your interpolations, try a double passage.

Code: Select all

screen blob():
    $ da_text = my_text[0]
    text "[da_text]"

Sorry for the late reply! I will try it!
Check out some of my stuffs here:https://linktr.ee/theartofjoshlab

Art Portfolio: https://www.instagram.com/theartofjoshlab/

Working on a personal Visual Novel~

User avatar
Trafagal
Regular
Posts: 100
Joined: Mon Apr 29, 2019 9:32 am
Contact:

Re: Having display time issues.

#5 Post by Trafagal »

gas wrote: Fri Dec 25, 2020 9:58 am
Hi Gas,

I seems to have problem, with the code you gave. I wonder if I need to do something,
exception1.JPG
Check out some of my stuffs here:https://linktr.ee/theartofjoshlab

Art Portfolio: https://www.instagram.com/theartofjoshlab/

Working on a personal Visual Novel~

User avatar
Trafagal
Regular
Posts: 100
Joined: Mon Apr 29, 2019 9:32 am
Contact:

Re: Having display time issues.

#6 Post by Trafagal »

Hi,

I'm back. I am still having a problem displaying my date. Hope to have some leads.

So this is what was shown when I play. The Output is a vairable which should be showing some date and time.
output.JPG
This is my code in screen.rpy to display the date/time.

Code: Select all

## Inititate a Date and Time.
    ## 0 is left hand side, whereas 1 is right hand side
    frame:
        xpos 0 ypos 0
        xminimum 1920
        yminimum 75
        ymaximum 75
        ## hbox to all the elements align horizontally. i.e Inventory, blood bar, time, etc.
        hbox:
            text "[Output]" xalign 0.5
           
Check out some of my stuffs here:https://linktr.ee/theartofjoshlab

Art Portfolio: https://www.instagram.com/theartofjoshlab/

Working on a personal Visual Novel~

User avatar
Alex
Lemma-Class Veteran
Posts: 3090
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Having display time issues.

#7 Post by Alex »

Trafagal wrote: Sat Jun 19, 2021 5:04 am ...
Check if your variable named Output (with capital O) and have a value before screen appears.
Also, you could try to show the value of variable in screen like

Code: Select all

text "{}".format(Output)

User avatar
Trafagal
Regular
Posts: 100
Joined: Mon Apr 29, 2019 9:32 am
Contact:

Re: Having display time issues.

#8 Post by Trafagal »

Hi Alex,

Thanks for your input. I will check that out. In the meanwhile, I tried creating another renpy project with the date, and it works. I will see whether it has to do with my current project not able to integrate with the date and time.
Check out some of my stuffs here:https://linktr.ee/theartofjoshlab

Art Portfolio: https://www.instagram.com/theartofjoshlab/

Working on a personal Visual Novel~

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]