Timer Component

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
JimmyFrost
Regular
Posts: 30
Joined: Fri May 01, 2015 9:46 am
Projects: TOWER
Location: United States
Contact:

Timer Component

#1 Post by JimmyFrost »

I want to build a Danganronpa-styled debate/battle system. Once upon a time, the tutorial section actually had the necessary scriptwork for me to rip apart and study, but it now seems to be gone. This is what I have thrown together for part of this in a class setting.

Code: Select all

import time
def timer(n)    :
while n > 0:
print    (n)
n = n - 1
if n == 0:
    print('Time Over')
It is currently incomplete and incompatible with Renpy as it stands. Where am I going wrong with this?
"If hard work hasn't hurt anyone, then why is there worker's comp?"

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2384
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Timer Component

#2 Post by Ocelot »

Function invocation is atomic: nothing else can happen until function finishes executing. So a loop inside of function is not a good idea. Why not use screen with Timer on it instead?
< < insert Rick Cook quote here > >

JimmyFrost
Regular
Posts: 30
Joined: Fri May 01, 2015 9:46 am
Projects: TOWER
Location: United States
Contact:

Re: Timer Component

#3 Post by JimmyFrost »

And that is the rub: I remember seeing that being part of the tutorial a few years back. I made the rookie mistake saying, "Oh, that's useless. I'll never use this." And now, here we are. My script above is based off of fifteen minutes of scanning the python tutorials and WikiHow, which is kind of not really helpful. So there's a dedicated screen with Timer?
"If hard work hasn't hurt anyone, then why is there worker's comp?"

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2384
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Timer Component

#4 Post by Ocelot »

There is even a simple example in RenPy documentaion: https://www.renpy.org/doc/html/screens.html#timer
< < insert Rick Cook quote here > >

JimmyFrost
Regular
Posts: 30
Joined: Fri May 01, 2015 9:46 am
Projects: TOWER
Location: United States
Contact:

Re: Timer Component

#5 Post by JimmyFrost »

I see it. Thank you very much everyone. Now, how do I close the thread?
"If hard work hasn't hurt anyone, then why is there worker's comp?"

Post Reply

Who is online

Users browsing this forum: Google [Bot], Imperf3kt, Kocker