Code: Select all
menu:
"A. Hello":
"B. Hi":
include("menu_chunk")
label menu_chunk:
"Special: Static Function 1":
$ func1()
"Special: Static Function 2":
$ func2()
Code: Select all
menu:
"A. Hello":
"B. Hi":
include("menu_chunk")
label menu_chunk:
"Special: Static Function 1":
$ func1()
"Special: Static Function 2":
$ func2()
Code: Select all
# menu_chunk = [("Special: Static Function 1", "func1"), ("Special: Static Function 2", "func2")]
menu (extra=menu_chunk ):
"a":
pass
# . . .
screen choice(items, extra=[]):
# Usual stuff
# After everything we add extra buttons:
for name, function in extra:
textbutton name action Function(function)
Unfortunately the special functions passed as an argument are not part of the choice index, so if you press the arrow down keys, it won't cycle to the extra menu chunk choices. They're accessible by mouse, but not by keyboard.Ocelot wrote: ↑Tue Jul 13, 2021 6:26 pm 1) Add an argument to the choice screen and pass your special functions as an argument:Code: Select all
# menu_chunk = [("Special: Static Function 1", "func1"), ("Special: Static Function 2", "func2")] menu (extra=menu_chunk ): "a": pass # . . . screen choice(items, extra=[]): # Usual stuff # After everything we add extra buttons: for name, function in extra: textbutton name action Function(function)
I'm going to try this solution next, perhaps it will allow me to add the special function choices, but also include them in the index, so they can be access with the arrow keys in addition to the mouse.Ocelot wrote: ↑Tue Jul 13, 2021 6:26 pm Or create a function to build your choice list and use renpy.display_menu to get your choices
https://www.renpy.org/doc/html/statemen ... splay_menu
Code: Select all
# screens.rpy
screen choice(items, extra=[]):
style_prefix "choice"
vbox:
for i in items:
textbutton i.caption action i.action
for name, function in extra:
textbutton name action Function(function)
# script.rpy
init python:
def func1():
renpy.jump("f1")
def func2():
renpy.jump("f2")
label start:
$ menu_chunk = [("Special: Static Function 1", func1), ("Special: Static Function 2", func2)]
menu (extra=menu_chunk ):
"a":
pass
"this is a test"
return
label f1:
"F1"
return
label f2:
"F2"
return
I actually did do that. I got my own custom menu screen. It's working great so far.
Damn, I need to up my game. I want to get as black belt as you. Thanks again.Ocelot wrote: ↑Tue Jul 13, 2021 7:15 pm Works for me, all buttons are selectable from the keyboard:Code: Select all
# screens.rpy screen choice(items, extra=[]): style_prefix "choice" vbox: for i in items: textbutton i.caption action i.action for name, function in extra: textbutton name action Function(function) # script.rpy init python: def func1(): renpy.jump("f1") def func2(): renpy.jump("f2") label start: $ menu_chunk = [("Special: Static Function 1", func1), ("Special: Static Function 2", func2)] menu (extra=menu_chunk ): "a": pass "this is a test" return label f1: "F1" return label f2: "F2" return
Users browsing this forum: Bing [Bot], Wildmask