Timer inside a 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.
- AoiUsui
- Regular
- Posts: 42
- Joined: Mon Nov 26, 2012 11:21 am
- Completed: Alice's Dolls
- Projects: Alice's Dolls, Tappy Virus
- Organization: Otaku Brigade
- itch: otakubrigade
- Location: Philippines
- Contact:
Timer inside a timer
We have a problem about timer, we used the sample codes found on the tutorial. After the countdown finishes, we need to time the blinking text (caption) for a minute then the countdown starts again from the start. It is actually a repetitive process. How can we made it like that?
We are beginners in Ren'Py.
Please, help us! Thanks in advance!
We are beginners in Ren'Py.
Please, help us! Thanks in advance!
- PyTom
- Ren'Py Creator
- Posts: 16093
- 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 inside a timer
Probably the easiest way is to use the module operator on st:
Code: Select all
st = st % 60
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
- AoiUsui
- Regular
- Posts: 42
- Joined: Mon Nov 26, 2012 11:21 am
- Completed: Alice's Dolls
- Projects: Alice's Dolls, Tappy Virus
- Organization: Otaku Brigade
- itch: otakubrigade
- Location: Philippines
- Contact:
Re: Timer inside a timer
Where can we insert that code? And does it make it repetitive?
init:
python:
# This function will run a countdown of the given length. It will
# be white until 5 seconds are left, and then red until 0 seconds are
# left, and then will blink 0.0 when time is up.
def countdown(st, at, length=0.0):
remaining = length - st
if remaining > 5.0:
return Text("%.1f" % remaining, color="#fff", size=25), .1
elif remaining > 0.0:
return Text("%.1f" % remaining, color="#f00", size=25), .1
else:
return anim.Blink(Text("Reminder: You are playing for more than 2 hours.", size=40 , color="#FF9900")), None
image countdown = DynamicDisplayable(countdown, length=5.0)
Thank you!
init:
python:
# This function will run a countdown of the given length. It will
# be white until 5 seconds are left, and then red until 0 seconds are
# left, and then will blink 0.0 when time is up.
def countdown(st, at, length=0.0):
remaining = length - st
if remaining > 5.0:
return Text("%.1f" % remaining, color="#fff", size=25), .1
elif remaining > 0.0:
return Text("%.1f" % remaining, color="#f00", size=25), .1
else:
return anim.Blink(Text("Reminder: You are playing for more than 2 hours.", size=40 , color="#FF9900")), None
image countdown = DynamicDisplayable(countdown, length=5.0)
Thank you!
Re: Timer inside a timer
Have fun.
Code: Select all
init:
python:
def countdown(st, at, length=0.0):
copied_st = st % (length + 60) # Had to copy "st", because "st" is NoneType and can't be operated with directly.
remaining = length - copied_st
while remaining >= 0:
return Text("%.1f" % remaining, color="#fff", size=25), .1
while remaining >= -60:
return anim.Blink(Text("0.0", color="#f00", size=64)), None
# Show a countdown for 10 seconds.
image countdown = DynamicDisplayable(countdown, length=15)
If your question is solved, please add [Solved] to theme's name by editing its first post, so that the helpful guys out there wouldn't mistakenly think the problem is still unanswered and waste their time.
- AoiUsui
- Regular
- Posts: 42
- Joined: Mon Nov 26, 2012 11:21 am
- Completed: Alice's Dolls
- Projects: Alice's Dolls, Tappy Virus
- Organization: Otaku Brigade
- itch: otakubrigade
- Location: Philippines
- Contact:
Re: Timer inside a timer
I will try this! Thank you very much!
It solved our problem! Thank you very much!
It solved our problem! Thank you very much!
- AoiUsui
- Regular
- Posts: 42
- Joined: Mon Nov 26, 2012 11:21 am
- Completed: Alice's Dolls
- Projects: Alice's Dolls, Tappy Virus
- Organization: Otaku Brigade
- itch: otakubrigade
- Location: Philippines
- Contact:
Re: Timer inside a timer
Its been a while since I first post this. But there is a version 2 of the game we are previously working at.
With this codes, how can we make the player to choose countdown time? For example: 30 minutes, 1 hour or 2 hours.
I hope that you can help me again.
Thanks.
With this codes, how can we make the player to choose countdown time? For example: 30 minutes, 1 hour or 2 hours.
I hope that you can help me again.
Thanks.
Re: Timer inside a timer
Have you seen this thread - viewtopic.php?f=8&t=7337&hilit=countdown?
- AoiUsui
- Regular
- Posts: 42
- Joined: Mon Nov 26, 2012 11:21 am
- Completed: Alice's Dolls
- Projects: Alice's Dolls, Tappy Virus
- Organization: Otaku Brigade
- itch: otakubrigade
- Location: Philippines
- Contact:
Re: Timer inside a timer
Thank you for the reply and for the link. I'm trying to incorporate it first in an experiment and I'm having an issue. I attach here the screenshot.
I hope that you can still help me in this. Thanks again.
I hope that you can still help me in this. Thanks again.
- Divona
- Miko-Class Veteran
- Posts: 678
- Joined: Sun Jun 05, 2016 8:29 pm
- Completed: The Falconers: Moonlight
- Organization: Bionic Penguin
- itch: bionicpenguin
- Contact:
Re: Timer inside a timer
You have "def countdown()" and "image countdown". I would try to avoid duplication name.
Also on line 9, instead of
Try:
Also on line 9, instead of
Code: Select all
python:
Code: Select all
init python:
- AoiUsui
- Regular
- Posts: 42
- Joined: Mon Nov 26, 2012 11:21 am
- Completed: Alice's Dolls
- Projects: Alice's Dolls, Tappy Virus
- Organization: Otaku Brigade
- itch: otakubrigade
- Location: Philippines
- Contact:
Re: Timer inside a timer
It seems that it solved the problem, but I still encountered an issue. It has no error messages but it doesn't work.
I'm sorry, I'm not a much into programming. But please help me. Thanks also.
I'm sorry, I'm not a much into programming. But please help me. Thanks also.
Code: Select all
label start:
e "Please choose countdown."
menu:
"10 Seconds":
jump sec10
"30 Seconds":
jump sec30
"60 Seconds":
jump sec60
label sec10:
init python:
# This function will run a countdown of the given length. It will
# be white until 5 seconds are left, and then red until 0 seconds are
# left, and then will blink 0.0 when time is up.
def countdown(st, at):
length = 10.0
if hasattr(store, 'bulles_temps'):
length = store.bulles_temps
remaining = length - st
if remaining > 5.0:
return Text("%.1f" % remaining, color="#fff", size=64), .1
elif remaining > 0.0:
return Text("%.1f" % remaining, color="#f00", size=64), .1
else:
#return anim.Blink(Text("0.0", color="#f00", size=64)), None
renpy.jump('end')
# Show a countdown for 10 seconds.
#image countdown = DynamicDisplayable(countdown)
e"You selected 10 seconds, please wait for 10 seconds."
return
Who is online
Users browsing this forum: Ahrefs [Bot], Andredron, Google [Bot]