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.
-
lindsay-jb
- Regular
- Posts: 61
- Joined: Tue Aug 25, 2020 1:05 am
-
Contact:
#1
Post
by lindsay-jb » Mon Apr 25, 2022 12:55 pm
Hey so I have the size of my narration box set up to choose the different backgrounds based on string size. the problem is that the string sizes aren't consistent. if words are longer, they get pushed to the next line sooner and vice versa. This means that frequently the textbox has a lot of white space because it's choosing a bigger box than necessary, and sometimes the text runs off the bottom. Is there away that I can set it up to be based on the ysize of the dialogue (what) instead? like:
Code: Select all
if ysize(what) <= 40:
background "gui/textbox/ns.png"
etc? Here is my current code. But I'd rather base it on the vertical position of the text rather than the string length since that varies.
Code: Select all
if who is None:
if who != who_old: # use transform for new sayer
add "gui/textbox/narrator tag.png" at narrator_tag_in:
pos(0,0.297)
window at narrator_in:
if len(what) <= 50:
background "gui/textbox/ns.png"
elif len(what) > 50 and len(what) <=75:
background "gui/textbox/nm.png"
elif len(what) > 75 and len(what) <=120:
background "gui/textbox/nl.png"
else:
background "gui/textbox/nxl.png"
id "middle"
style "middle"
text what id "what"
if who == who_old: # use transform for new sayer
add "gui/textbox/narrator tag.png":
pos(0,0.297)
window:
if len(what) <= 50:
background "gui/textbox/ns.png"
elif len(what) > 50 and len(what) <=75:
background "gui/textbox/nm.png"
elif len(what) > 75 and len(what) <=120:
background "gui/textbox/nl.png"
else:
background "gui/textbox/nxl.png"
id "middle"
style "middle"
text what id "what"
-
m_from_space
- Veteran
- Posts: 302
- Joined: Sun Feb 21, 2021 3:36 am
-
Contact:
#2
Post
by m_from_space » Tue May 10, 2022 7:22 am
You should make yourself familiar with using frames. The Frame()-Displayable can adapt its size to their parent (e.g. a frame it is put in).
"frame" as part of screens:
https://www.renpy.org/doc/html/screens.html#frame
Frame() as a Displayable:
https://www.renpy.org/doc/html/displaya ... rame#Frame
You could use something like this, no need for any calculation. The background will stretch when text is bigger. I hope that's what you want.
Code: Select all
screen say(who, what):
window:
id "window"
frame:
background Frame("images/textbox/nm.png")
xalign 0.5
yalign 1.0
xmaximum 300
text what id "what"
Make sure to not use the default window style, since it overwrites position of the window and dialogue via config entries.
Users browsing this forum: enaielei, Google [Bot]