Timer
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.
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.
- usul
- Veteran
- Posts: 415
- Joined: Mon Oct 29, 2007 12:35 pm
- Projects: Teachings of the Buddha, System-Addict, Generation XxX
- Location: Quebec
- Contact:
Timer
How do you start a timer to calculate the time it takes to complete a task?
"The universe is non-simultaneously apprehended"
— Buckminster Fuller
— Buckminster Fuller
Re: Timer
It`s something like this
http://www.renpy.org/wiki/ui.timer
Code: Select all
label start:
scene black
$ ui.timer(30.0, ui.jumps("too_slow"))
$ ui.textbutton("Press me", clicked=ui.returns(True), xalign=.6, yalign=.3)
$ ui.interact()
"You did it...))"
return
label too_slow:
"... ..."
return
- usul
- Veteran
- Posts: 415
- Joined: Mon Oct 29, 2007 12:35 pm
- Projects: Teachings of the Buddha, System-Addict, Generation XxX
- Location: Quebec
- Contact:
Re: Timer
yeah that part I get, I've seen it around the posts a lot these days, what I'm looking to do would be more like telling you how long it took.
something like:
timer start
user input
timer stop
it took you n seconds to respond
something like:
timer start
user input
timer stop
it took you n seconds to respond
"The universe is non-simultaneously apprehended"
— Buckminster Fuller
— Buckminster Fuller
- usul
- Veteran
- Posts: 415
- Joined: Mon Oct 29, 2007 12:35 pm
- Projects: Teachings of the Buddha, System-Addict, Generation XxX
- Location: Quebec
- Contact:
Re: Timer
I found this on python.org, I think it might be of use in trying to figure out the time at the start and end of a task then calculating the difference. Not sure how I'll put it together yet, butI'll try to get it working tonight.
Code: Select all
>>> # dates are easily constructed and formatted
>>> from datetime import date
>>> now = date.today()
>>> now
datetime.date(2003, 12, 2)
>>> now.strftime("%m-%d-%y. %d %b %Y is a %A on the %d day of %B.")
'12-02-03. 02 Dec 2003 is a Tuesday on the 02 day of December.'
>>> # dates support calendar arithmetic
>>> birthday = date(1964, 7, 31)
>>> age = now - birthday
>>> age.days
14368
"The universe is non-simultaneously apprehended"
— Buckminster Fuller
— Buckminster Fuller
- PyTom
- Ren'Py Creator
- Posts: 16096
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: Timer
I'd probably use the similar:
Code: Select all
init python:
import time
$ start = time.time()
e "Go ahead, take your time."
$ time_taken = time.time() - start
e "You took %(time_taken)f seconds."
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
-
- Eileen-Class Veteran
- Posts: 1153
- Joined: Mon Jul 07, 2003 4:57 pm
- Completed: Elven Relations, Cloud Fairy, When I Rule The World
- Tumblr: alextfish
- Skype: alextfish
- Location: Cambridge, UK
- Contact:
Re: Timer
What code are you using precisely? Is it character-for-character copypasted from PyTom's post? And can you post the full error message and traceback?
I released 3 VNs, many moons ago: Elven Relations (IntRenAiMo 2007), When I Rule The World (NaNoRenO 2005), and Cloud Fairy (the Cute Light & Fluffy Project, 2009).
More recently I designed the board game Steam Works (published in 2015), available from a local gaming store near you!
More recently I designed the board game Steam Works (published in 2015), available from a local gaming store near you!
- usul
- Veteran
- Posts: 415
- Joined: Mon Oct 29, 2007 12:35 pm
- Projects: Teachings of the Buddha, System-Addict, Generation XxX
- Location: Quebec
- Contact:
Re: Timer
My bad, it works just fine (I transcribed it from my cellphone when offline but having copy-pasted it today It works like a charm)
Thanks!!!
Thanks!!!
"The universe is non-simultaneously apprehended"
— Buckminster Fuller
— Buckminster Fuller
Who is online
Users browsing this forum: Bing [Bot]