Ren'py Timed menu confusion. >_<
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.
Ren'py Timed menu confusion. >_<
I am trying to incorporate a timed menu for the menu choices I currently have. Now I have tried racking my brain to figure out the wiki, as well as the somewhat newly updated post. Still, to no avail can I create a timed menu to add. Too many errors popping up when I try to copy part of the code into the script, (which from the wiki's point says anywhere in the script) when I attempt to add it. I'm sure to some the wiki is a simple way to do it, but for a beginner such as I, this is like rocket science here. Please help?
Re: Ren'py Timed menu confusion. >_<
Well, the cookbook on the wiki (I assume you're referring to http://www.renpy.org/wiki/renpy/doc/coo ... imed_menus ) works fine for me...
If something is buggy, try running it in its simplest form. Literally, tack this onto a brand new project (which will have Eileen ("e") defined by default) and it should run fine. I'll throw in some comments to try to make how the code works more explicit?
If something is buggy, try running it in its simplest form. Literally, tack this onto a brand new project (which will have Eileen ("e") defined by default) and it should run fine. I'll throw in some comments to try to make how the code works more explicit?
Code: Select all
transform alpha_dissolve:
alpha 0.0
linear 0.5 alpha 1.0
on hide:
linear 0.5 alpha 0
# This is to fade the bar in and out, and is only required once in your script
init: ### just setting variables in advance so there are no undefined variable problems
$ timer_range = 0
$ timer_jump = 0
$ time = 0
screen countdown:
timer 0.01 repeat True action If(time > 0, true=SetVariable('time', time - 0.01), false=[Hide('countdown'), Jump(timer_jump)])
### ^this code decreases variable time by 0.01 until time hits 0, at which point, the game jumps to label timer_jump (timer_jump is another variable that will be defined later)
bar value time range timer_range xalign 0.5 yalign 0.9 xmaximum 300 at alpha_dissolve
# ^This is the timer bar.
# The game starts here.
label start:
label menu1:
$ time = 5 ### set variable time to 5
$ timer_range = 5 ### set variable timer_range to 5 (this is for purposes of showing a bar)
$ timer_jump = 'menu1_slow' ### set where you want to jump once the timer runs out
show screen countdown ### call and start the timer
menu:
"Choice 1":
hide screen countdown ### stop the timer
e "You chose 'Choice 1'"
jump menu1_end
"Choice 2":
hide screen countdown
e "You chose 'Choice 2'"
jump menu1_end
label menu1_slow:
e "You didn't choose anything."
label menu1_end:
e "Anyway, let's do something else."
- Googaboga
- Eileen-Class Veteran
- Posts: 1395
- Joined: Wed Dec 12, 2012 1:37 pm
- Completed: https://gbpatch.itch.io/
- Projects: Floret Bond, XOXO Blood Droplets, Our Life
- Organization: GB Patch Games
- Tumblr: gb-patch
- itch: gbpatch
- Contact:
Re: Ren'py Timed menu confusion. >_<
Well depending on what you want you can have a timed menu by just putting something like this:
right above the word "menu:" in your script.
The 2.0 part is how long the timer lasts. You can make the time longer or shorter by changing that. "menu1_slow" is a label. That part determines the scene that happens if you don't click any option during the time given. You can change the "menu1_slow" to any label you want.
After you've got that set up you make the menu like any other menu.
Here is a little example of it all put together.
But I'm not exactly sure what you want out of your timed menu so that may not be right for you and you may need something a little more complex.
Code: Select all
$ ui.timer(2.0, ui.jumps("menu1_slow"))The 2.0 part is how long the timer lasts. You can make the time longer or shorter by changing that. "menu1_slow" is a label. That part determines the scene that happens if you don't click any option during the time given. You can change the "menu1_slow" to any label you want.
After you've got that set up you make the menu like any other menu.
Here is a little example of it all put together.
Code: Select all
'I am walking in the woods when suddenly I hear a noise.'
'"What was that?"'
$ ui.timer(2.0, ui.jumps("menu1_slow"))
menu:
"Call out.":
'"Hello? Is someone there?"'
'I think I hear another noise in response to my call so I follow the sound.'
return
"Look around.":
'I look back and forth to see if something is out there.'
'I think I see a figure in the distance so I walk towards it.'
return
return
label menu1_slow:
'"It was probably nothing."'
'I go back to what I was doing.'
returnIn-Progress:
Floret Bond, XOXO Blood Droplets, Our Life
Released:
A Foretold Affair, My Magical Divorce Bureau, XOXO Droplets, Lake of Voices
Floret Bond, XOXO Blood Droplets, Our Life
Released:
A Foretold Affair, My Magical Divorce Bureau, XOXO Droplets, Lake of Voices
Re: Ren'py Timed menu confusion. >_<
Thank you guys so much for the help. It's exactly what I wanted. 
Philat, I also feel like I understand the coding better thanks to the comment break downs; thank you for that
The thing now is that when I test run the game using the code you posted, it works, but it's not letting me select any choices. I can't figure out why. Lol, maybe I'm being dumb. Thoughts?
Philat, I also feel like I understand the coding better thanks to the comment break downs; thank you for that
The thing now is that when I test run the game using the code you posted, it works, but it's not letting me select any choices. I can't figure out why. Lol, maybe I'm being dumb. Thoughts?
-
AfterForever
- Newbie
- Posts: 10
- Joined: Thu Feb 06, 2014 1:05 pm
- Contact:
Re: Ren'py Timed menu confusion. >_<
I'm actually having the same problem. This is what my menu looks like so far. Help please?
Code: Select all
label menu17:
$ time = 3
$ timer_range = 3
$ timer_jump = 'nomaya'
show screen countdown
menu:
"Don't take Maya along.":
hide screen countdown
jump nomaya
"Take Maya along.":
hide screen countdown
jump yesmaya
label nomaya:
t "Blah blah blah."Re: Ren'py Timed menu confusion. >_<
The problem might be in timer (it takes too much CPU resourses). Try to change it to
Code: Select all
screen countdown:
timer time repeat False action [Hide('countdown'), Jump(timer_jump)]
# rest of the code Re: Ren'py Timed menu confusion. >_<
Well, it's hard to be sure without looking at the rest of the code, but I would guess it's an indentation problem... that's usually a good guess for python.
AfterForever, you have the four lines starting from $ time = 3 under menu17 indented twice. Once you fix the indentation (and presumably you already have a label yesmaya...) it should work.
EDIT: If you change the code per Alex's suggestion, the timer itself will work, but the shrinking bar won't. The bar shows time/timer_range, meaning if you don't go through the trouble of decreasing time, the bar will stay full. If you don't need the bar, which after all is neat but not essential, you can simplify the code.
AfterForever, you have the four lines starting from $ time = 3 under menu17 indented twice. Once you fix the indentation (and presumably you already have a label yesmaya...) it should work.
EDIT: If you change the code per Alex's suggestion, the timer itself will work, but the shrinking bar won't. The bar shows time/timer_range, meaning if you don't go through the trouble of decreasing time, the bar will stay full. If you don't need the bar, which after all is neat but not essential, you can simplify the code.
-
AfterForever
- Newbie
- Posts: 10
- Joined: Thu Feb 06, 2014 1:05 pm
- Contact:
Re: Ren'py Timed menu confusion. >_<
@ Alex -- I substituted the code in, but the game skipped right over the dialogue choices. Like xOrochix, I'm a total newbie at this, too. I'm convinced that it's something easy, but, for some reason I'm just overlooking it.
@ Philat -- I'm sure that it's an indentation problem I overlooked, I just can't seem to find it, lol. I tried using the code you supplied up at the top, but I'm getting the same situation on that run through too. The coding looks like this:
This is how my own game script (with the yesmaya and no maya) looks too. I went back and fixed the indentation that you mentioned in my own script, but to no avail. Thank you for any and all thoughts 
@ Philat -- I'm sure that it's an indentation problem I overlooked, I just can't seem to find it, lol. I tried using the code you supplied up at the top, but I'm getting the same situation on that run through too. The coding looks like this:
Code: Select all
# You can place the script of your game in this file.
# Declare images below this line, using the image statement.
# eg. image eileen happy = "eileen_happy.png"
# Declare characters used by this game.
define e = Character('Eileen', color="#c8ffc8")
transform alpha_dissolve:
alpha 0.0
linear 0.5 alpha 1.0
on hide:
linear 0.5 alpha 0
# This is to fade the bar in and out, and is only required once in your script
init: ### just setting variables in advance so there are no undefined variable problems
$ timer_range = 0
$ timer_jump = 0
$ time = 0
screen countdown:
timer 0.01 repeat True action If(time > 0, true=SetVariable('time', time - 0.01), false=[Hide('countdown'), Jump(timer_jump)])
### ^this code decreases variable time by 0.01 until time hits 0, at which point, the game jumps to label timer_jump (timer_jump is another variable that will be defined later)
bar value time range timer_range xalign 0.5 yalign 0.9 xmaximum 300 at alpha_dissolve
# ^This is the timer bar.
# The game starts here.
label start:
e "You've created a new Ren'Py game."
e "Once you add a story, pictures, and music, you can release it to the world!"
label menu1:
$ time = 5 ### set variable time to 5
$ timer_range = 5 ### set variable timer_range to 5 (this is for purposes of showing a bar)
$ timer_jump = 'menu1_slow' ### set where you want to jump once the timer runs out
show screen countdown ### call and start the timer
menu:
"Choice 1":
hide screen countdown ### stop the timer
jump menu_1
"Choice 2":
hide screen countdown
jump menu_1
label menu_1slow:
e "You didn't choose anything."
label menu_1:
e "Anyway, let's do something else."
returnRe: Ren'py Timed menu confusion. >_<
Ooops, didn't saw the bar... Actually, you can just fake it, like
http://www.renpy.org/doc/html/screen_ac ... tml#values
@AfterForever
The code you've posted working fine for me... are you shure to save changes and start a new game (not restore from previously made save)?
Code: Select all
screen timer_test:
timer time repeat False action [Hide("timer_test"),Jump("far_away")]
bar value AnimatedValue(0, time, time, time) xmaximum 200 xalign 0.5 yalign 0.05
label start:
$ time = 7
show screen timer_test
"."
".."
"..."
return
label far_away:
"?"@AfterForever
The code you've posted working fine for me... are you shure to save changes and start a new game (not restore from previously made save)?
- SundownKid
- Lemma-Class Veteran
- Posts: 2299
- Joined: Mon Feb 06, 2012 9:50 pm
- Completed: Icebound, Selenon Rising Ep. 1-2
- Projects: Selenon Rising Ep. 3-4
- Organization: Fastermind Games
- Deviantart: sundownkid
- Location: NYC
- Contact:
Re: Ren'py Timed menu confusion. >_<
Actually, the AnimatedValue doesn't work. Since "time" is a constantly changing variable, the bar's range will also change unless a separate range is defined.
If you can figure out how to set the range to the INITIAL value of time, it might work, but otherwise two variables are required.
If you can figure out how to set the range to the INITIAL value of time, it might work, but otherwise two variables are required.
-
AfterForever
- Newbie
- Posts: 10
- Joined: Thu Feb 06, 2014 1:05 pm
- Contact:
Re: Ren'py Timed menu confusion. >_<
Alex, your code worked
Thank you so much! For some reason, the original code wouldn't work for me, even though everyone else said it worked. I still don't know why. But the timer_test is working fine.
And thanks to everyone who gave their help and thoughts. It's made me understand the coding just a little bit better
And thanks to everyone who gave their help and thoughts. It's made me understand the coding just a little bit better
- JanstinBeebo
- Newbie
- Posts: 20
- Joined: Sun Mar 25, 2018 12:38 pm
- Contact:
Re: Ren'py Timed menu confusion. >_<
Hate to bring up this old topic, but it came in handy for my current project. Script above works perfectly except for one thing:
As long as a countdown bar is present, non of the menu options display the hover image when the mouse is hovering above it. You can still click the buttons and everything works functionally, but I would like the "hover over" buttons to still be present. Is this normal? If so, any way around it?
I guess to add another dimension to my issue... This is a part in the game that has 26 menus in a row. I want a timer on all of them... is there a way to automate this and simplify things or do I have to keep copying and pasting the script for each menu and redefining the labels to be jumped to when time runs out? Otherwise it's going to just get stuck on jumping to the label right before the first menu...
As long as a countdown bar is present, non of the menu options display the hover image when the mouse is hovering above it. You can still click the buttons and everything works functionally, but I would like the "hover over" buttons to still be present. Is this normal? If so, any way around it?
I guess to add another dimension to my issue... This is a part in the game that has 26 menus in a row. I want a timer on all of them... is there a way to automate this and simplify things or do I have to keep copying and pasting the script for each menu and redefining the labels to be jumped to when time runs out? Otherwise it's going to just get stuck on jumping to the label right before the first menu...
- Remix
- Eileen-Class Veteran
- Posts: 1628
- 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: Ren'py Timed menu confusion. >_<
If you are ok with altering your choice screen (the default one is in screens.rpy) you can basically toggle in a timer and bar based on modes...
It does make the inline code easier on the eyes and fingers as it just needs:
renpy.mode( [ "timed_menu", 2.5, [ SetVariable('var', 'value'), Jump('too_late') ] ] )
# [ mode name, timer seconds, actions on timeout ]
Hover seems to work too
Overloaded screen choice and example menu:
It does make the inline code easier on the eyes and fingers as it just needs:
renpy.mode( [ "timed_menu", 2.5, [ SetVariable('var', 'value'), Jump('too_late') ] ] )
# [ mode name, timer seconds, actions on timeout ]
Hover seems to work too
Overloaded screen choice and example menu:
Code: Select all
style choice_bar:
xalign 0.5
yalign 0.5
xmaximum 300
screen choice(items):
style_prefix "choice"
default timer_opts = [ 0, NullAction() ]
python:
if isinstance(renpy.game.context().modes[1], (list,tuple)) \
and renpy.game.context().modes[1][0] == 'timed_menu':
timer_opts = renpy.game.context().modes[1][1:]
vbox:
if timer_opts[0]:
timer timer_opts[0]:
repeat False
action timer_opts[1]
bar:
value AnimatedValue(0, 1, timer_opts[0], 1)
for i in items:
textbutton i.caption action i.action
label start:
"Start"
$ renpy.mode( ["timed_menu", 4.0, Jump('too_late')])
menu:
"Timed Menu Question"
"Choice 1":
"Dialogue 1"
"Choice 2":
"Dialogue 2"
"Middle"
menu:
"Untimed Menu Question"
"Choice 1":
"Dialogue 1"
"Choice 2":
"Dialogue 2"
"End"
return
label too_late:
"too late"Frameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
- JanstinBeebo
- Newbie
- Posts: 20
- Joined: Sun Mar 25, 2018 12:38 pm
- Contact:
Re: Ren'py Timed menu confusion. >_<
Remix:
Okay I've implemented that code and it's coming along. Game runs and menus are successfully timed. Hover is good, too. The problem I'm running into is this:
All menus in the game that take place before the first timed menu [[ the one I'd declared with $ renpy.mode( ["timed_menu", 8.0, Jump('b')]) ]] are not timed. That's fine, I want that. However, ALL menus that take place after that timed menu have a timer on them regardless of whether it has the "Timed_menu" renpy.mode line.
I don't know if this is something I need to fix in the screens or script, but do you have any idea why this is the case? Do you need me to copy/paste some of my game's code?
Thanks so much for the help. I really appreciate the time.
Okay I've implemented that code and it's coming along. Game runs and menus are successfully timed. Hover is good, too. The problem I'm running into is this:
All menus in the game that take place before the first timed menu [[ the one I'd declared with $ renpy.mode( ["timed_menu", 8.0, Jump('b')]) ]] are not timed. That's fine, I want that. However, ALL menus that take place after that timed menu have a timer on them regardless of whether it has the "Timed_menu" renpy.mode line.
I don't know if this is something I need to fix in the screens or script, but do you have any idea why this is the case? Do you need me to copy/paste some of my game's code?
Thanks so much for the help. I really appreciate the time.
- Remix
- Eileen-Class Veteran
- Posts: 1628
- 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: Ren'py Timed menu confusion. >_<
Strange... not entirely sure what is going wrong tbhJanstinBeebo wrote: ↑Tue Mar 27, 2018 3:43 pmAll menus in the game that take place before the first timed menu [[ the one I'd declared with $ renpy.mode( ["timed_menu", 8.0, Jump('b')]) ]] are not timed. That's fine, I want that. However, ALL menus that take place after that timed menu have a timer on them regardless of whether it has the "Timed_menu" renpy.mode line.
I don't know if this is something I need to fix in the screens or script, but do you have any idea why this is the case? Do you need me to copy/paste some of my game's code?
Almost 3am here so will just leave a debug option and maybe try further tomorrow (later today)
Code: Select all
screen last_3_modes():
vbox:
for m in renpy.game.context().modes[:3]:
$ m = str(m).replace('[','[[')
text "[m]"
init python:
config.overlay_screens.append('last_3_modes')Frameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
Who is online
Users browsing this forum: Google [Bot], Ocelot
