is there a function that counts the played time per session?

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
abeplaga
Regular
Posts: 34
Joined: Mon Oct 15, 2018 10:09 am
Contact:

is there a function that counts the played time per session?

#1 Post by abeplaga » Mon Dec 30, 2019 11:12 pm

Hi! I just discovered that there is a variable that counts the game time (renpy.get_game_runtime), and I wondered if there is a variable that stores how long a game has been running in a play session. In other words, that count the time everytime the player runs the executable of the game.

If there isn't, how could it be created? Maybe a screen with a timer that adds a second to the variable every second? ... but I think it's a bit wrong :s

philat
Eileen-Class Veteran
Posts: 1751
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: is there a function that counts the played time per session?

#2 Post by philat » Tue Dec 31, 2019 12:37 am

get_game_runtime IS per session.

User avatar
abeplaga
Regular
Posts: 34
Joined: Mon Oct 15, 2018 10:09 am
Contact:

Re: is there a function that counts the played time per session?

#3 Post by abeplaga » Tue Dec 31, 2019 6:15 am

philat wrote:
Tue Dec 31, 2019 12:37 am
get_game_runtime IS per session.
I've done tests and no, it starts counting from the moment you enter the script and stays stored in the saves.

I ask for a function that counts from the moment the player executes the .exe of the game and always starts at 0.

User avatar
Remix
Eileen-Class Veteran
Posts: 1455
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: is there a function that counts the played time per session?

#4 Post by Remix » Tue Dec 31, 2019 7:51 am

There isn't one natively (not as far as I know anyway)

You could just reset the game_runtime wherever you want though with renpy.clear_game_runtime(), e.g.

Code: Select all

label splashscreen():
    $ renpy.clear_game_runtime()
    return
Frameworks & Scriptlets:

User avatar
abeplaga
Regular
Posts: 34
Joined: Mon Oct 15, 2018 10:09 am
Contact:

Re: is there a function that counts the played time per session?

#5 Post by abeplaga » Wed Jan 01, 2020 7:45 pm

Remix wrote:
Tue Dec 31, 2019 7:51 am
There isn't one natively (not as far as I know anyway)

You could just reset the game_runtime wherever you want though with renpy.clear_game_runtime(), e.g.

Code: Select all

label splashscreen():
    $ renpy.clear_game_runtime()
    return
I tried it with but doesn't work. Maybe because runtime starts when the player loads a save slot or starts a new game. If you clear runtime before that doesn't happen.

philat
Eileen-Class Veteran
Posts: 1751
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: is there a function that counts the played time per session?

#6 Post by philat » Wed Jan 01, 2020 10:14 pm

My bad, I remembered there was an issue with get_game_runtime but was remembering the wrong one -- the one I was thinking of is it participates in rollback, which seems to defeat its purpose lol. Anyway, in short, no, there isn't one out of the box.

Post Reply

Who is online

Users browsing this forum: hell_oh_world, SavedByZero