Putting the choices menu IN the textbox?
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.
- Aurélie
- Regular
- Posts: 58
- Joined: Thu Aug 29, 2013 11:27 pm
- Organization: Lyonesse
- Location: London, England
- Contact:
Putting the choices menu IN the textbox?
I want to put the choices in the textbox, as though they're part of regular dialogue. Is this possible? I'm willing to do whatever I need to for it, like making a seperate textbox or whatever.
I've attached some pictures to better illustrate what I mean.
This is the regular talking.
And this is what I want for choices!
I've attached some pictures to better illustrate what I mean.
This is the regular talking.
And this is what I want for choices!
Re: Putting the choices menu IN the textbox?
I don't think that answer the question though. She want to put the menu items in the say box. What that code does is make the menu look like a say box. While that might seems good enough, it lacks the functionality of the say statement. The code for handling a menu where you want a (non-narrator) character speaking at the same time as the menu is being shown is deep inside the engine, and what it does is that it call a separate say statement and a separate menu statement, and so the menu and the say window don't work together. You will either end up with the character on the wrong window, the menu overlapping over the text, or a lot of extra code every single time you need a menu. All these problems can be avoided with some...uhh...gymnastics...Alex wrote:http://lemmasoft.renai.us/forums/viewto ... 41#p250130 - should help.
Re: Putting the choices menu IN the textbox?
Ok, I got this code to work. At least as far as I tested, no errors is found. So here it is:
Add code
Step 1. Add this new class somewhere:
2. After label start, create this object like this:
Note that doing this in init block don't work (well it will work, but you might have rollback/save issue later)
3. Add in this new screen:
4. (assuming you are still using something resembling the default say screen with only style differences) Search through the say screen and replace any instance of:
with this
Make sure the indentation is correct.
Then also add this at the top of the say screen code, right after screen say:
with proper indentation.
5. Replace the choice screen code with this:
6. Adjust the style setting if necessary. Since you want to add in bullets and all, and have the name of the left side in the padding region. Also, you need to reduce the xmaximum and xminimum of menu button otherwise it could potentially extend outside of the screen, because the default setting only work for buttons in the center, not when you have paddings.
How to use
To display a menu without any characters associated to it, simply do not have any character speak. Like this:
To display a menu with a character name, but do not have any lines, you need to have that character speak an empty line. Like this:
To display a menu without any character associated to it, but have some caption, simply have the narrator speak. Like this:
To display a menu with a character speak, have that character speak. Like this:
Modification
1. Modify the choice_main screen code to change the menu layout. Make sure a few important stuff are there though, such as the content of the button being taken from canonical_menu.items for example.
2. The screen code for choice screen is used only if there is no one talking and no caption. Modify it if you want the layout to change in such case. In that code I attempted to make it mimic the say box, but it might not make sense if there is no character speaking.
3. Add in some python code if you want to handle situation when the layout look different if the narrator is talking compared to other case.
4. Modify your say screen layout to make the name appear at the correct place. Modify the style of the button to remove the border and make the colour match the say box colour background. Also add in the bullets.
Hope it help.
Add code
Step 1. Add this new class somewhere:
Code: Select all
init -100 python:
class MenuInformation(renpy.store.object):
def __init__(self):
super(renpy.store.object,self).__init__()
global menu
self.activated=False
self.items=[]
self.say_aru=False
self.original_iu=renpy.exports.say
self.original_senkoo=menu
renpy.exports.say=self.iu
menu=self.senkoo
def iu(self,who,what,interact=True):
self.activated=False
self.say_aru=not interact
self.items=[]
return self.original_iu(who,what,interact)
def senkoo(self,items):
self.activated=True
ret=self.original_senkoo(items)
self.activated=False
self.say_aru=False
return ret
Code: Select all
label start:
$menu_info=MenuInformation()
3. Add in this new screen:
Code: Select all
screen choice_main:
default canonical_menu=menu_info
for caption, action, chosen in canonical_menu.items:
if action:
button:
action action
style "menu_choice_button"
text caption style "menu_choice"
else:
text caption style "menu_caption"
Code: Select all
text what id "what"
Code: Select all
if what:
text what id "what"
use choice_main
if not what:
text "" id "what"
Then also add this at the top of the say screen code, right after screen say:
Code: Select all
default canonical_menu=menu_info
5. Replace the choice screen code with this:
Code: Select all
screen choice:
default canonical_menu=menu_info
python:
canonical_menu.items=items
if not canonical_menu.say_aru:
window:
id "window"
vbox:
style "say_vbox"
use choice_main
How to use
To display a menu without any characters associated to it, simply do not have any character speak. Like this:
Code: Select all
menu:
#add choice here
Code: Select all
menu:
vincent "" #have vincent speak an empty line here
#add choice here
Code: Select all
menu:
"Have you decided?"
#add choice here
Code: Select all
menu:
vincent "Have you decided?"
#add choice here
1. Modify the choice_main screen code to change the menu layout. Make sure a few important stuff are there though, such as the content of the button being taken from canonical_menu.items for example.
2. The screen code for choice screen is used only if there is no one talking and no caption. Modify it if you want the layout to change in such case. In that code I attempted to make it mimic the say box, but it might not make sense if there is no character speaking.
3. Add in some python code if you want to handle situation when the layout look different if the narrator is talking compared to other case.
4. Modify your say screen layout to make the name appear at the correct place. Modify the style of the button to remove the border and make the colour match the say box colour background. Also add in the bullets.
Hope it help.
- Aurélie
- Regular
- Posts: 58
- Joined: Thu Aug 29, 2013 11:27 pm
- Organization: Lyonesse
- Location: London, England
- Contact:
Re: Putting the choices menu IN the textbox?
I can't believe I only just saw this, thanks so much Elmi!
- Aracade
- Regular
- Posts: 34
- Joined: Thu Mar 30, 2017 11:04 am
- Completed: A Monster's Insight, LUNACY, Gulam
- Github: arkicade
- itch: arkicade
- Contact:
Re: Putting the choices menu IN the textbox?
I don't know if anyone is going to see this (since this thread hasn't been touched for 5 years) ^^; , but unfortunately with these new pieces of
code there's an error that occurs WHEN SAVING (pressing the save button)
I'm sorry, but an uncaught exception occurred.
While running game code:
File "renpy/common/00gamemenu.rpy", line 173, in script
$ ui.interact()
File "renpy/common/00gamemenu.rpy", line 173, in <module>
$ ui.interact()
File "renpy/common/00action_file.rpy", line 357, in __call__
renpy.save(fn, extra_info=save_name)
PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed
code there's an error that occurs WHEN SAVING (pressing the save button)
I'm sorry, but an uncaught exception occurred.
While running game code:
File "renpy/common/00gamemenu.rpy", line 173, in script
$ ui.interact()
File "renpy/common/00gamemenu.rpy", line 173, in <module>
$ ui.interact()
File "renpy/common/00action_file.rpy", line 357, in __call__
renpy.save(fn, extra_info=save_name)
PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed
- xavimat
- Eileen-Class Veteran
- Posts: 1460
- Joined: Sat Feb 25, 2012 8:45 pm
- Completed: Yeshua, Jesus Life, Cops&Robbers
- Projects: Fear&Love, unknown
- Organization: Pilgrim Creations
- Github: xavi-mat
- itch: pilgrimcreations
- Location: Spain
- Contact:
Re: Putting the choices menu IN the textbox?
Well, we are going to see it because you have resurrected it
Please, be careful when using old code. RenPy is constantly developing (thanks to Pytom!) and it's better to learn how to do things the current way.
EDIT: I see you have already opened a new post.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)
Who is online
Users browsing this forum: Majestic-12 [Bot]