I have a feeling this is a pretty basic question but somehow I can’t find any info on it. I’d like the name box to have 500px padding only if the side image is displayed, otherwise, I’d like it to stay at 300px padding. I’m not sure how to configure this, could anyone point me in the right direction? Thank you so much!
Name box padding only if side image is present
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.
Name box padding only if side image is present
Hello!
I have a feeling this is a pretty basic question but somehow I can’t find any info on it. I’d like the name box to have 500px padding only if the side image is displayed, otherwise, I’d like it to stay at 300px padding. I’m not sure how to configure this, could anyone point me in the right direction? Thank you so much!
I have a feeling this is a pretty basic question but somehow I can’t find any info on it. I’d like the name box to have 500px padding only if the side image is displayed, otherwise, I’d like it to stay at 300px padding. I’m not sure how to configure this, could anyone point me in the right direction? Thank you so much!
Re: Name box padding only if side image is present
One way you could do it is to modify the say screen in screens.rpy. Add a condition to check if SideImage() is present, and change the namebox position beneath it.
Re: Name box padding only if side image is present
Hi! Sorry for the second reply. I'm pretty new with python so I can't seem to figure out the syntax for this statement. right now I wrote something along this line
Code: Select all
if SideImage() = True:
style "namebox"
else
xpos = 200Re: Name box padding only if side image is present
A couple of notes first looking at your code:
1) Conditional statements (if/while etc.) always take a double equal sign (== True) instead of a single equal sign (= True) which is used to define or change variables
2) In renpy screens, you won't need the = equal sign between arguments, so you should do "xpos 200" instead of "xpos = 200"
These two points would lead to errors if you try to run the game, so don't forget that screen language is different from script language!
Since "add SideImage()" would show a Null() displayable if no side image is present, I imagined this code would work, but it didn't:
Unfortunately the condition for SideImage() did not work as intended, perhaps because the function for SideImage() don't work so simply and did not return Null(). Anyways, since I'm no expert and couldn't find the SideImage() function underneath the hood, I searched the documentation for ways to get around it. This is what I finally found:
Tested it and it worked! However, I only tested this with side images, if you are using "show image" and side images at the same time, be aware of the speaking character and its image tag, as that might affect what is returned with the renpy.get_say_image_tag().
1) Conditional statements (if/while etc.) always take a double equal sign (== True) instead of a single equal sign (= True) which is used to define or change variables
2) In renpy screens, you won't need the = equal sign between arguments, so you should do "xpos 200" instead of "xpos = 200"
These two points would lead to errors if you try to run the game, so don't forget that screen language is different from script language!
Since "add SideImage()" would show a Null() displayable if no side image is present, I imagined this code would work, but it didn't:
Code: Select all
if who is not None:
window:
id "namebox"
style "namebox"
text who id "who"
if SideImage(): #other ones I tried along the lines: if SideImage() == Null(), if not SideImage()... etc.
xpos gui.name_xpos #note that I didn't wrap the entire style "namebox" inside here, because that might mess up your other style settings, so all you need to change is the xpos, this would only replace the xpos and nothing else under the namebox style
else:
xpos 200
Given the description, this could work with side images, so I altered the above code to:renpy.get_say_image_tag()
Returns the tag corresponding to the currently speaking character (the image argument given to that character). Returns None if no character is speaking or the current speaking character does not have a corresponding image tag. https://www.renpy.org/doc/html/displayi ... _image_tag
Code: Select all
if who is not None:
window:
id "namebox"
style "namebox"
text who id "who"
if renpy.get_say_image_tag():
xpos gui.name_xpos
else:
xpos 200
Re: Name box padding only if side image is present
omg wow, the code worked perfectly!!! I really appreciate the effort you put in for your detailed explanation and help, and I'll take note of your general coding advice as wellemz911 wrote: ↑Thu May 27, 2021 7:32 pmA couple of notes first looking at your code:
1) Conditional statements (if/while etc.) always take a double equal sign (== True) instead of a single equal sign (= True) which is used to define or change variables
2) In renpy screens, you won't need the = equal sign between arguments, so you should do "xpos 200" instead of "xpos = 200"
These two points would lead to errors if you try to run the game, so don't forget that screen language is different from script language!
Since "add SideImage()" would show a Null() displayable if no side image is present, I imagined this code would work, but it didn't:Unfortunately the condition for SideImage() did not work as intended, perhaps because the function for SideImage() don't work so simply and did not return Null(). Anyways, since I'm no expert and couldn't find the SideImage() function underneath the hood, I searched the documentation for ways to get around it. This is what I finally found:Code: Select all
if who is not None: window: id "namebox" style "namebox" text who id "who" if SideImage(): #other ones I tried along the lines: if SideImage() == Null(), if not SideImage()... etc. xpos gui.name_xpos #note that I didn't wrap the entire style "namebox" inside here, because that might mess up your other style settings, so all you need to change is the xpos, this would only replace the xpos and nothing else under the namebox style else: xpos 200Given the description, this could work with side images, so I altered the above code to:renpy.get_say_image_tag()
Returns the tag corresponding to the currently speaking character (the image argument given to that character). Returns None if no character is speaking or the current speaking character does not have a corresponding image tag. https://www.renpy.org/doc/html/displayi ... _image_tagTested it and it worked! However, I only tested this with side images, if you are using "show image" and side images at the same time, be aware of the speaking character and its image tag, as that might affect what is returned with the renpy.get_say_image_tag().Code: Select all
if who is not None: window: id "namebox" style "namebox" text who id "who" if renpy.get_say_image_tag(): xpos gui.name_xpos else: xpos 200
Re: Name box padding only if side image is present
You are very welcome!! Learning code is basically a process of trial-and-error and flipping through documentations
, so I strongly recommend looking up keywords on the Renpy documentation (or this forum) whenever you are stuck: https://www.renpy.org/doc/html/index.html
Anyways, glad to help!!
Anyways, glad to help!!
Who is online
Users browsing this forum: No registered users