Buttons on the text box/hud (SOLVED)
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:
Buttons on the text box/hud (SOLVED)
Hey guys,
I'm looking for a way to include buttons in the text box to fuction as a sort of hud. These buttons would allow the player to reach a screen and perform actions after which he could resume the game. Is this possible/simple?
If anyone can point me in the right direction for this I'd appreciate it.
I'm looking for a way to include buttons in the text box to fuction as a sort of hud. These buttons would allow the player to reach a screen and perform actions after which he could resume the game. Is this possible/simple?
If anyone can point me in the right direction for this I'd appreciate it.
Last edited by usul on Fri Apr 24, 2009 8:53 am, edited 1 time in total.
"The universe is non-simultaneously apprehended"
— Buckminster Fuller
— Buckminster Fuller
- killdream
- Veteran
- Posts: 325
- Joined: Wed Nov 05, 2008 1:05 pm
- Projects: EVūL (WIP), insilo (WIP), Cute Demon Crashers!
- Deviantart: robotlolita
- Github: robotlolita
- Location: World's End (aka Brazil)
- Contact:
Re: Buttons on the text box/hud
For text box, you mean, the dialog box? There's a recipe in Ren'Py's cookbook for it.
Here you go:
http://renpy.org/wiki/renpy/doc/cookboo ... _Game_Menu
Here you go:
http://renpy.org/wiki/renpy/doc/cookboo ... _Game_Menu
- 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: Buttons on the text box/hud
Cool, it works!
I only have one bug and that's if the button is pressed twice, you see the page, but then once you exit the page is brought up again.
Is there a way to make this button toggle the page instead of just calling it?
Oh and how do I replace the text buttons by custom images?
I only have one bug and that's if the button is pressed twice, you see the page, but then once you exit the page is brought up again.
Is there a way to make this button toggle the page instead of just calling it?
Code: Select all
ui.textbutton("Inventory", clicked=ccinc("inventory"), xminimum=80)
"The universe is non-simultaneously apprehended"
— Buckminster Fuller
— Buckminster Fuller
-
- Eileen-Class Veteran
- Posts: 1265
- Joined: Fri Aug 31, 2007 7:02 am
- Projects: 0 completed game. Still haven't made any meaningfully completed games...
- Contact:
Re: Buttons on the text box/hud
You can use if like so:usul wrote:Is there a way to make this button toggle the page instead of just calling it?
Code: Select all
if show_button:
ui.textbutton("Inventory", clicked=ccinc("inventory"), xminimum=80)
You can use ui.imagebutton. You can read about it here:http://www.renpy.org/wiki/renpy/doc/ref ... magebuttonusul wrote:Oh and how do I replace the text buttons by custom images?
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.
- 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: Buttons on the text box/hud
Code: Select all
On line 165 of /home/usul/system-addict_001/game/script.rpy: expected statement.
show_button=None
^
On line 173 of /home/usul/system-addict_001/game/script.rpy: expected statement.
show_button=True
^
Thanks in advance.
"The universe is non-simultaneously apprehended"
— Buckminster Fuller
— Buckminster Fuller
Re: Buttons on the text box/hud
You should probably be writing
with a $ sign. I personally don't think it's a good idea to use the value None, but you can use that instead of False if you want and it would work the same.
(by the way, I'm expanding the Button Game Menu page again as I type this because there have been a few questions about that lately)
EDIT: Okay, I added a humongous section near the end, and I still haven't even touched how the "clicked=x" portion works and what to do there. I'm a little scared that I might have gone too lengthy, but there's also the problem that I'm not explaining how the functions work well enough for non-programmers to understand. Comments would be nice.
Code: Select all
$ show_button = False
#...
$ show_button = True
(by the way, I'm expanding the Button Game Menu page again as I type this because there have been a few questions about that lately)
EDIT: Okay, I added a humongous section near the end, and I still haven't even touched how the "clicked=x" portion works and what to do there. I'm a little scared that I might have gone too lengthy, but there's also the problem that I'm not explaining how the functions work well enough for non-programmers to understand. Comments would be nice.
- 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: Buttons on the text box/hud
Ok while trying to add images to replace the text buttons I got an error:
Here's the full code of that section:
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:
# 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.99, ypos=0.98, xanchor='right', yanchor='bottom')
#ui.textbutton("Inventory", clicked=ccinc("inventory"), xminimum=80)
ui.frame(xalign=.5,yalign=.5)
ui.imagebutton("images/system/inv_icon.png", "images/system/inv_icon_hover.png", clicked=ccinc("inventory"))
ui.interact()
ui.textbutton("Save", clicked=ccinc("_game_menu_save"), xminimum=80)
ui.textbutton("Load", clicked=ccinc("_game_menu_load"), xminimum=80)
ui.textbutton("Prefs", clicked=ccinc("_game_menu_preferences"), xminimum=80)
ui.close()
config.overlay_functions.append(button_game_menu)
"The universe is non-simultaneously apprehended"
— Buckminster Fuller
— Buckminster Fuller
Re: Buttons on the text box/hud
You should probably take out the ui.interact.
- 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: Buttons on the text box/hud
Ok very cool!
How do I get rid of the box around my image. It's a box created with the theme's color. In fact I'd like to get rid of the theme altogether in other areas like the main menu and such. I bet there's a command fo that too right?
How do I get rid of the box around my image. It's a box created with the theme's color. In fact I'd like to get rid of the theme altogether in other areas like the main menu and such. I bet there's a command fo that too right?
"The universe is non-simultaneously apprehended"
— Buckminster Fuller
— Buckminster Fuller
Re: Buttons on the text box/hud
Remove the ui.frame().usul wrote:Ok very cool!
How do I get rid of the box around my image. It's a box created with the theme's color.
You mean create your own theme? ("Getting rid" of it might cause problems, such as not being able to see the main menu at all and thus the player not being able to play your game. ) Creating your own theme is a little bit harder.usul wrote: In fact I'd like to get rid of the theme altogether in other areas like the main menu and such.
The documentation is over at renpy.org/wiki, on pages such as Customizing the Interface and Properties and Styles. If you want to make the menus into images, layout.imagemap_main_menu helps. (I don't really know what you're trying to do here, so yeah...)
- 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: Buttons on the text box/hud
Ok removing the ui frame worked except it got rid of the coordonates for the placement of the button. It's now in the upper left corner by default.
I tried adding them to the image line but I get an error.
I tried adding them to the image line but I get an error.
"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: Buttons on the text box/hud
Ok I figured it out. Adding the following at the end did it:
Code: Select all
xalign=.98,yalign=0.8
"The universe is non-simultaneously apprehended"
— Buckminster Fuller
— Buckminster Fuller
Who is online
Users browsing this forum: Google [Bot]