Custom choice menu statement? [SOLVED]

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
mikolajspy
Regular
Posts: 169
Joined: Sun Jun 04, 2017 12:05 pm
Completed: Too many, check signature
Deviantart: mikolajspy
Location: Wrocław, Poland
Contact:

Custom choice menu statement? [SOLVED]

#1 Post by mikolajspy »

Hi!
For my new project, I want to use few different choice menus depending on situation.
Sometimes I'd use classic, vertical, one column.
But sometimes, I'd like to use horizontal or double-column vertical.
While changing choice screen is not a problem, I don't know how to use duplicate with custom statement.

I've already read Documentation: https://www.renpy.org/doc/html/cds.html

But I don't really know how to use it.
What I'd like to achieve is something just like:

Code: Select all

hmenu:
	"Option 1":
	....
	"Option 2":
	...
And it would result with horizontal styled menu.
And so on if I type "menu2" etc. it would use different layout.

Can someone point me how do I use custom statements to create choice menu?

Or at least, just how to show different choice menu screen with button jump label actions etc.
Last edited by mikolajspy on Wed Oct 18, 2017 2:29 pm, edited 1 time in total.

User avatar
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: Custom choice menu statement?

#2 Post by Remix »

The current Ren'py menu: statement parses the statement parts in a sort of ad-hoc manner then mashes them all together to fit in with rollback/save/roll-forward/choice locking/remembering and the rest.
As such, it is a bit of a beast to meaningfully extend unless you get quite familiar with the code surrounding the standard menu: block. Even then, you would likely be writing the new lexer/parser and then rewriting a version of the ui.menu function to fit the menu varieties you want.

I would therefore recommend just passing a flag/toggle in with the first choice caption and using the screen choice( items ): to work out what to display...

Pseudo code - probably might need some parts in $ or python: blocks...

Code: Select all


label a:
    menu:
        "h1:Choice A":
...

screen choice(items):
    style_prefix "choice"

    if items[0].caption[:3] == 'h1:':
        items[0].caption = items[0].caption[3:]
        use choice_horizontal_1( items )

    # etc for different styles
Then just write small screens to display each 'first menu item prefix' differently
Frameworks & Scriptlets:

mikolajspy
Regular
Posts: 169
Joined: Sun Jun 04, 2017 12:05 pm
Completed: Too many, check signature
Deviantart: mikolajspy
Location: Wrocław, Poland
Contact:

Re: Custom choice menu statement?

#3 Post by mikolajspy »

Of course, variable! I didn't think about it! Thanks for the idea! I made it even easier.
In the end, I just added

Code: Select all

default menu_style = "v"
and later in choice screen, before vbox

Code: Select all

if menu_style == "v":
and below vbox part

Code: Select all

if menu_style == "h":
#Code for another layout
Now I just change variable right before showing menu and it works smoothly :D

Post Reply

Who is online

Users browsing this forum: Andredron, Bing [Bot], Google [Bot]