Lemma Soft Forums

Supporting creators of visual novels and story-based games since 2003.


Visit our new games list, blog aggregator, IRC, and wiki.
Activation problem? Email [email protected]
It is currently Sat May 25, 2013 6:29 am

All times are UTC - 5 hours [ DST ]


Forum rules


Ask questions about one topic per thread, and use a descriptive subject. "NotImplemented error in script.rpy" is a good subject, "Tom's problems" is not. Remember to include all of traceback.txt or error.txt when reporting a problem, as well as the relevant lines of script. Use the [code] tag to format scripts.



Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: Time count
PostPosted: Sun Jun 24, 2012 5:20 pm 
Veteran

Joined: Mon Mar 26, 2012 6:51 pm
Posts: 389
Location: Philadelphia
Projects: Amy's Super Life!
How do I make a game count the time in minutes that a players plays it so that I can put this:

You finished the demo in _____. Congrats!

_________________
My blog : http://briannafactory.blogspot.com/


Top
 Profile Send private message  
 
 Post subject: Re: Time count
PostPosted: Sun Jun 24, 2012 6:40 pm 
Veteran

Joined: Tue Jun 05, 2012 2:01 am
Posts: 378
Code:
$ minutes, seconds = divmod(int(renpy.get_game_runtime()), 60)
"It took you [minutes] minutes and [seconds] seconds to finish this demo."


Top
 Profile Send private message  
 
 Post subject: Re: Time count
PostPosted: Sun Jun 24, 2012 7:12 pm 
Veteran

Joined: Mon Mar 26, 2012 6:51 pm
Posts: 389
Location: Philadelphia
Projects: Amy's Super Life!
apricotorange wrote:
Code:
$ minutes, seconds = divmod(int(renpy.get_game_runtime()), 60)
"It took you [minutes] minutes and [seconds] seconds to finish this demo."


It does not seem to be counting the time played. No matter how long I play it, it says "It took you 0 minutes and 0 seconds to finish this demo."

_________________
My blog : http://briannafactory.blogspot.com/


Top
 Profile Send private message  
 
 Post subject: Re: Time count
PostPosted: Sun Jun 24, 2012 7:49 pm 
Veteran

Joined: Tue Jun 05, 2012 2:01 am
Posts: 378
That's strange... that exact code appears to work just fine for me.


Top
 Profile Send private message  
 
 Post subject: Re: Time count
PostPosted: Sun Jun 24, 2012 8:11 pm 
Veteran

Joined: Mon Mar 26, 2012 6:51 pm
Posts: 389
Location: Philadelphia
Projects: Amy's Super Life!
Can someone please help me with this :(

_________________
My blog : http://briannafactory.blogspot.com/


Top
 Profile Send private message  
 
 Post subject: Re: Time count
PostPosted: Sun Jun 24, 2012 9:59 pm 
Veteran
User avatar

Joined: Fri Nov 11, 2011 12:26 am
Posts: 204
Location: Look behind you
Completed: Of Stupidity and Idiotic
Strange... that same code works for me perfectly.

Can you show me the script where you put the code? Remember those two lines should be put at the end of your demo.

_________________
DA | Commission is open


Last edited by Michiyo6918 on Mon Jun 25, 2012 3:08 pm, edited 1 time in total.

Top
 Profile Send private message  
 
 Post subject: Re: Time count (solved)
PostPosted: Sun Jun 24, 2012 11:54 pm 
Veteran

Joined: Mon Mar 26, 2012 6:51 pm
Posts: 389
Location: Philadelphia
Projects: Amy's Super Life!
It's fixed now! Thanks everybody! :D

_________________
My blog : http://briannafactory.blogspot.com/


Top
 Profile Send private message  
 
 Post subject: Re: Time count (solved)
PostPosted: Mon Jun 25, 2012 12:24 am 
Veteran
User avatar

Joined: Fri Nov 11, 2011 12:26 am
Posts: 204
Location: Look behind you
Completed: Of Stupidity and Idiotic
briannavon wrote:
It's fixed now! Thanks everybody! :D


That's good. Wish you luck on releasing the next demo of your game :)

_________________
DA | Commission is open


Top
 Profile Send private message  
 
 Post subject: Re: Time count
PostPosted: Mon Jun 25, 2012 12:20 pm 
Miko-Class Veteran
User avatar

Joined: Fri Mar 16, 2012 11:38 am
Posts: 940
Location: Tokyo, Japan
Projects: Untitled Japanese study game
Organization: Pure Anarchy
I'm having a little trouble too.

Here is the exact code I'm using:

Code:
label start:
    scene black
    "The timer should start from now"
    $ minutes, seconds = divmod(int(renpy.get_game_runtime()), 60)
    "Let this run for a bit"
    "Let it run a little more, so it uses time."
    "Ok, now let's see the result."
    "It took you [minutes] minutes and [seconds] seconds to finish this demo."

It seems to work, but only between "The timer should start from now." and "Let this run for a bit".
Is there any way to keep it running while other things happen? This code would be extremely useful to me if it could do that.

_________________
Working on a VN to teach lower-conversational Japanese, and a guide to living in Japan.
It's a very long dev process.

You could help me with my game A LOT by filling out this anonymous 10 question survey: http://www.surveymonkey.com/s/6GR57YB
Massive thanks to everyone who has already filled it out!
You can see a Q&A about the survey here: http://tinyurl.com/SurveyQandA


Top
 Profile Send private message  
 
 Post subject: Re: Time count
PostPosted: Mon Jun 25, 2012 12:51 pm 
Miko-Class Veteran
User avatar

Joined: Fri Mar 16, 2012 11:38 am
Posts: 940
Location: Tokyo, Japan
Projects: Untitled Japanese study game
Organization: Pure Anarchy
Nevermind, I figured it out too. I thought the timer started from the first line of code, not from when the game started, until I read Michiyo6918's message again.
I just set up a couple of variables to record the start of the timed section, and took that time away from the end of the timed section.

Code:
    "The timer should start next"
    $ temp_minutes, temp_seconds = divmod(int(renpy.get_game_runtime()), 60)
    "The actual gameplay that you want to time should go here."
    $ temp_minutes2, temp_seconds2 = divmod(int(renpy.get_game_runtime()), 60)
    $ minutes = temp_minutes2 - temp_minutes
    $ seconds = temp_seconds2 - temp_seconds
    "It took you [minutes] minutes and [seconds] seconds to finish this demo."

_________________
Working on a VN to teach lower-conversational Japanese, and a guide to living in Japan.
It's a very long dev process.

You could help me with my game A LOT by filling out this anonymous 10 question survey: http://www.surveymonkey.com/s/6GR57YB
Massive thanks to everyone who has already filled it out!
You can see a Q&A about the survey here: http://tinyurl.com/SurveyQandA


Top
 Profile Send private message  
 
 Post subject: Re: Time count
PostPosted: Mon Jun 25, 2012 6:20 pm 
Ren'Py Creator
User avatar

Joined: Mon Feb 02, 2004 10:58 am
Posts: 10780
Location: Kings Park, NY
Completed: Moonlight Walks
Projects: Ren'Py
Note that that code is wrong, since you can wind up with a negative number of seconds. Your best bet is to subtract the seconds first, and then do the divmod.

_________________
Another Old-Fashioned Bishoujo Gamer
Supporting creators since 2004; Code > Drama
(When was the last time you backed up your game?)
"It is not the critic who counts; not the man who points out how the strong man stumbles, or where the doer of deeds could have done them better. The credit belongs to the man who is actually in the arena, whose face in marred by dust and sweat and blood; who strives valiantly; who errs, who comes short again and again, because there is no effort without error and shortcoming" - Theodore Roosevelt


Top
 Profile Send private message  
 
 Post subject: Re: Time count
PostPosted: Mon Jun 25, 2012 9:11 pm 
Miko-Class Veteran
User avatar

Joined: Fri Mar 16, 2012 11:38 am
Posts: 940
Location: Tokyo, Japan
Projects: Untitled Japanese study game
Organization: Pure Anarchy
I've been using this code in my game, because I just need it rounded to the closest minute:
Code:
    $ temp_minutes2, temp_seconds2 = divmod(int(renpy.get_game_runtime()), 60) # To record the current gameplay time.
    $ minutes = temp_minutes2 - temp_minutes # To figure out how many minutes the search took.
    $ seconds = temp_seconds2 - temp_seconds # To figure out how many seconds the search took.
    if seconds > 30: # Rounding up to the nearest minute.
        $ minutes += 1
    if seconds < -30: # Strangely, sometimes the seconds show as negative numbers.  This will counteract that.
        $ minutes += 1
 


But I know people check these topics for their own problems, so maybe I should add the code other people would use.
I was a little confused about what you meant though, so I hacked together my own ugly way of doing it.

Code:
    $ temp_minutes2, temp_seconds2 = divmod(int(renpy.get_game_runtime()), 60) # To record the current gameplay time.
    $ minutes = temp_minutes2 - temp_minutes # To figure out how many minutes the search took.
    if temp_seconds2 >= temp_seconds:
        $ seconds = temp_seconds2 - temp_seconds # To figure out how many seconds the search took.
    else:
        $ seconds = temp_seconds - temp_seconds2 # To figure out how many seconds the search took.
 

_________________
Working on a VN to teach lower-conversational Japanese, and a guide to living in Japan.
It's a very long dev process.

You could help me with my game A LOT by filling out this anonymous 10 question survey: http://www.surveymonkey.com/s/6GR57YB
Massive thanks to everyone who has already filled it out!
You can see a Q&A about the survey here: http://tinyurl.com/SurveyQandA


Top
 Profile Send private message  
 
 Post subject: Re: Time count
PostPosted: Tue Jun 26, 2012 5:38 am 
Miko-Class Veteran
User avatar

Joined: Tue Jul 24, 2007 12:58 pm
Posts: 526
PyTom means just get the raw runtime both times and only divmod it at the end if you want to put it into minutes.

$ firsttime = renpy.get_game_runtime()
"Lalala"
$ secondtime = renpy.get_game_runtime()
$ minutes, seconds = divmod(int(secondtime-firsttime), 60)


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: Bing [Bot]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Protected by Anti-Spam ACP
Powered by phpBB® Forum Software © phpBB Group