I have custom code that takes Menu choices in the script and presents them to the players as a grid of text buttons. The code works perfectly in Ren'Py 7.4.11, and does exactly what I want it to. If there are only 2 choices, it shows 2 buttons. If there are 6 choices, it shows 6 buttons. If there are more than 6 buttons, it displays a message for the player to scroll down for more choices. Perfect.
Code: Select all
screen choice(items):
style_prefix "choice"
frame:
background None
xalign 0.5
ypos 1089
vpgrid id "cgrid":
cols 3
xspacing 0
yspacing 42
draggable True
mousewheel True
ysize 238
# Creates a custom caption system for menu choices, allowing additional feedback
# to the player. Results are displayed in the screen 'descriptions'.
$ choice_count = 0
for i in items:
$ tt = i.caption[i.caption.find("(")+1:i.caption.find(")")]
$ ti = i.caption[i.caption.find("<")+1:i.caption.find(">")]
$ caption = i.caption.replace(" ("+tt+")", "").replace(" <"+ti+">", "")
$ choice_count += 1
textbutton caption:
background "gui/choice_idle.webp"
hover_background "gui/choice_hover.webp"
hovered [SetVariable("choice_description", tt), SetVariable("talent_indicator", ti)]
unhovered [SetVariable("choice_description", ""), SetVariable("talent_indicator", "")]
action [i.action, SetVariable("choice_description", ""), SetVariable("talent_indicator", "")]
if choice_count > 6:
text "{font=fonts/Montserrat-Medium.otf}{size=35}{color=#c75e73}▼ {/color}{color=#e9e2cf}Scroll Down for More Choices{/color}{color=#c75e73} ▼{/color}{/size}{/font}":
ypos 1370
xpos 1277
xalign 0.5
yalign 0.5
In Ren'Py 8.0.0.22061101, I get a crash.
Now, conceptually, I can see what is wrong. The menu that is causing this crash only has 2 choices, so 2 text buttons to generate, and because the VPGrid in my code has 3 columns, Ren'Py has decided to freak out because the grid isn't full - hence the "needs a multiple of 3 children".Exception: VPGrid not completely full, needs a multiple of 3 children.
The problem is I don't know how to make Ren'Py 8 happy with my code, since by the nature of what I'm doing, I don't want to have to always present menu choices in multiples of 3. So what is it I'm doing wrong, and why does my code work in 7.4.11 but not in 8.0?
EDIT: The answer, for anyone else experiencing this, is to add:
Code: Select all
define config.allow_underfull_grids = True