Conditional Menu
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.
Conditional Menu
I've ran in to a another dilemma. I hope that someone can help me.
So I want to create a custom menu that's always show on the screen and it enables the player to move from one room to another.
The menu is shown, but clicking on the buttons doesn't do anything. Now I know that something needs to be done in the menu code to make it work but I don't know how.
Also I want those functions of the menu buttons to change. For example, player can't enter a specific room until he/she has done specific action.
I hope that someone can post a simple code and explain how it works.
So I want to create a custom menu that's always show on the screen and it enables the player to move from one room to another.
The menu is shown, but clicking on the buttons doesn't do anything. Now I know that something needs to be done in the menu code to make it work but I don't know how.
Also I want those functions of the menu buttons to change. For example, player can't enter a specific room until he/she has done specific action.
I hope that someone can post a simple code and explain how it works.
- Alera
- Miko-Class Veteran
- Posts: 651
- Joined: Sun Mar 21, 2010 3:20 am
- Completed: Tortichki // Zayay // Hero's Spirit
- Deviantart: psyalera
- itch: psyalera
- Location: UK
- Contact:
Re: Conditional Menu
Could you post the codes you use now? It will make it easier to modify.
Re: Conditional Menu
Sure, here is the code.
The code is in its own file to keep things organized.
Code: Select all
init python:
meni_kuca = True
def meni_kuca_funk():
if meni_kuca:
ui.hbox(xpos=0, ypos=0.75, xanchor='left', yanchor='bottom')
ui.textbutton("Kuhinja", clicked=kuhinja, xminimum=80)
ui.textbutton("Stepenice", clicked=stepenice, xminimum=80)
ui.close()
config.window_overlay_functions.append(meni_kuca_funk)Re: Conditional Menu
It seems you need to def what you are going to do when the kuhinja and stepenice button being clicked
Code: Select all
def kuhinja():
#do something
def stepenice():
#do something
Re: Conditional Menu
But what does go under def?
I already tried with jump kuhinja, to jump to the label in my code but it says it's an invalid syntax.
I already tried with jump kuhinja, to jump to the label in my code but it says it's an invalid syntax.
Re: Conditional Menu
did you tried this?
clicked=ui.jumps("kuhinja")
http://www.renpy.org/wiki/renpy/doc/ref ... s/ui.jumps
or ui.return may help...
http://www.renpy.org/wiki/renpy/doc/ref ... ui.returns
see the second example in this reference
clicked=ui.jumps("kuhinja")
http://www.renpy.org/wiki/renpy/doc/ref ... s/ui.jumps
or ui.return may help...
http://www.renpy.org/wiki/renpy/doc/ref ... ui.returns
see the second example in this reference
- Airetta
- Regular
- Posts: 25
- Joined: Sat Apr 09, 2011 12:00 pm
- Projects: Miracle Days: YourLife VS The Reality
- Contact:
Re: Conditional Menu
humm hey i have a question in same condition
this code shows vertical menu. i want to make it to horizontal menu. how?
Code: Select all
init python:
# Give us some space on the right side of the screen.
style.window.right_padding = 100
def toggle_skipping():
config.skipping = not config.skipping
show_button_game_menu = True
def button_game_menu():
if show_button_game_menu:
# to save typing
ccinc = renpy.curried_call_in_new_context
ui.vbox(xpos=0.35, ypos=0.75, xanchor='bottom', yanchor='right')
ui.textbutton("Skip", clicked=toggle_skipping, xminimum=80)
ui.textbutton("Save", clicked=ccinc("_game_menu_save"), xminimum=80)
ui.textbutton("Load", clicked=ccinc("_game_menu_load"), xminimum=80)
ui.textbutton("Opt", clicked=ccinc("_game_menu_preferences"), xminimum=80)
ui.textbutton("Menu", clicked=ccinc(), xminimum=80)
ui.close()Sorry guys, my English is so bad 
My Blogsite: http://utysama.aoindonesia.net/
Miracle Days: YourLife VS TheReality: http://lemmasoft.renai.us/forums/viewto ... 5&p=129221
My Blogsite: http://utysama.aoindonesia.net/
Miracle Days: YourLife VS TheReality: http://lemmasoft.renai.us/forums/viewto ... 5&p=129221
Re: Conditional Menu
@Airetta: Use hbox instead of vbox.
@shuen: I think that ui,jumps is the functions I need. I'll have a look at it later when I have time.
@shuen: I think that ui,jumps is the functions I need. I'll have a look at it later when I have time.
Re: Conditional Menu
The menu is now functional and I've gotten it work with conditions.
Now one last things bugs me. For example, player was told that he can't enter a room. And using a menu he needs to go back to previous rooms to complete some tasks. I have a problem if I click after the game told me that I can't do anything it'll finish the game or go to the next instructions.
I want Ren'Py to wait until the player has clicked an option in the menus.
Now one last things bugs me. For example, player was told that he can't enter a room. And using a menu he needs to go back to previous rooms to complete some tasks. I have a problem if I click after the game told me that I can't do anything it'll finish the game or go to the next instructions.
I want Ren'Py to wait until the player has clicked an option in the menus.
Re: Conditional Menu
You need to loop the game until the tasks complete
for example:
for example:
Code: Select all
# The game starts here.
label start:
# All opening staffs put here
"I enter the Hotel"
$ haskey = False
jump lobby
# The game loop here
label lobby:
"I'm in lobby now"
jump chooser
label chooser:
"Choose a room"
menu:
"Room1":
jump room1
"Room2":
jump room2
"Room3":
jump room3
label room1:
if haskey:
"I unlock the door of Room1!"
return # end the game loop
else:
"The door is locked, I need a key to open it..."
jump lobby
label room2:
"This room is empty..."
jump lobby
label room3:
"Hey I find a key!"
$ haskey = True
jump lobby
- Mild Curry
- Regular
- Posts: 107
- Joined: Fri Jul 02, 2010 3:03 pm
- Projects: That's The Way The Cookie Crumbles
- Organization: TwinTurtle Games
- Contact:
Re: Conditional Menu
Hmm...well, looping might work, but there's a simpler solution.
Try adding:
right after your ui.close().
It pauses the program until the user clicks a button. That is what you wanted,right?
Try adding:
Code: Select all
func = ui.interact()
func() It pauses the program until the user clicks a button. That is what you wanted,right?
Re: Conditional Menu
Thank you both. I think that Curry's solution is better so I'll use his.
But now I get an error.
And the code looks like this.
First I thought that func needs to be replaced with my functions name, meni_kuca_funk. But that doesn't help. What is wrong here?
But now I get an error.
Code: Select all
Exception: ui.interact called with non-empty widget/layer stack. Did you forget a ui.close() somewhere?Code: Select all
init python:
meni_kuca = True
def meni_kuca_funk():
if meni_kuca:
ui.hbox(xpos=0, ypos=0.75, xanchor='left', yanchor='bottom')
ui.textbutton("Kuhinja", clicked=ui.jumps("kuhinja"), xminimum=80)
ui.close()
func = ui.interact()
func()
config.window_overlay_functions.append(meni_kuca_funk)- Mild Curry
- Regular
- Posts: 107
- Joined: Fri Jul 02, 2010 3:03 pm
- Projects: That's The Way The Cookie Crumbles
- Organization: TwinTurtle Games
- Contact:
Re: Conditional Menu
Ahh....okay. It seems that that solution won't work inside a function. The code runs fine when placed in the regular program, but something goes screwy when it's inside a function.
I'm sorry; I haven't had much experience in that area, so I have no idea why it works that way...^^'';
I'm sorry; I haven't had much experience in that area, so I have no idea why it works that way...^^'';
Re: Conditional Menu
I've put it in my main script. Here is that part.
Now it doesn't exit from my game but it hides text box and the menu from the screen for some reason.
Code: Select all
label kuhinja:
"Test"
if kuhinja:
c "Rucak!"
$ ui.interact()
else:
c "Moram prvo da operem ruke."
$ kuhinja = True
c "Ruke su oprane."
$ ui.interact()Re: Conditional Menu
shuen's method of looping works. Based off the code you've shown you could try something like this:
Code: Select all
init python:
meni_kuca = False
def meni_kuca_funk():
if meni_kuca:
ui.hbox(xpos=0, ypos=0.75, xanchor='left', yanchor='bottom')
ui.textbutton("Kuhinja", clicked=ui.jumps("kuhinja"), xminimum=80)
ui.close()
config.window_overlay_functions.append(meni_kuca_funk)
label story_before:
"Stuff happens earlier in story"
$ meni_kuca = True
jump waitforclick
label waitforclick:
"Waiting for the button to be clicked"
if meni_kuca:
jump waitforclick
label kuhinja:
$ meni_kuca = False
"Turn off button and the story continues on"
#etc etc whatever
Who is online
Users browsing this forum: Majestic-12 [Bot]



