Hello All and thank you for any assistance you are willing to give.
I am working on a relationship-type VN whereas the MC is liked or mistrusted by the NPCs. Blah blah, we all know this type of game.
So i have a typical stat Friendship scaled 1-16 nothing crazy
However, my idea is this
As the variable of friendship changes, I would like to change the dialog box to match...
Example:
Friendship = 0 default black border
Friendship = 5 A red box with hearts
Friendship = 10 a purple box with flowers
Friendship = 15 gold box
the actual image doesn't matter where I am having a hard time is getting the image to change per character per friendship variable
Does that make sense? I feel like i am either missing something or maybe overthinking it but I just can't seem to get it to work.
Anyhow again thank you for your thoughts and assistance.
-Shatter
[Solved] Variable Dialog Box
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.
[Solved] Variable Dialog Box
Last edited by Shatter on Wed Apr 13, 2022 3:58 pm, edited 1 time in total.
-
Xiael
- Regular
- Posts: 31
- Joined: Thu Aug 06, 2020 9:13 am
- itch: Xiael
- Discord: message me first here
- Contact:
Re: Variable Dialog Box
Hello to solve your problem, you have to break it down to small parts first. Let's lay down the specs that you want to do:
1 You want the dialogue box to change per character
2 Each character has their variable friendship points
3 Each dialogue box has different modes depending on the friendship points per character
Now that we know what to look for, we need to find the unique variable that differentiates each character first so that we can determine which dialogue box to use.
Suppose you have a character chara1.
First, how do we know who's talking and who's not?
If you look at the say screen, you'll find that there's a variable called who.
In this case, who stands for the name of the character speaking "Char". But we don't want that, because it may change for cases when you re-set a character's name. Two characters may have the same name too, and yet they may have different dialogue boxes, therefore we should avoid using that. So what we actually want is chara1, which won't ever change throughout your game, and that variable is stored in _last_say_who
So now that we have the unique variable that differs per character. We go ahead and set that in the Say Screen.
Next, we'll need a dynamic image that changes based on certain variables. Thankfully, we can use ConditionSwitch() (https://www.renpy.org/doc/html/displaya ... tionSwitch if you want to read more).
We will use this to set the background of the window based on the variable friendship that you have made per capturable character. In this case, I set friendship_char1 as the variable that decides which image to use. And with that, here's the final ConditionSwitch():
And with that you now have a working code on changing the image based on the variables _last_say_who (who's talking) and friendship_char1. Next step is to automate that process for the other characters, but I'll leave that part for you to experiment on if you wanna :^>
Goodluck with your project!
1 You want the dialogue box to change per character
2 Each character has their variable friendship points
3 Each dialogue box has different modes depending on the friendship points per character
Now that we know what to look for, we need to find the unique variable that differentiates each character first so that we can determine which dialogue box to use.
Suppose you have a character chara1.
Code: Select all
define chara1= Character(name="Char")If you look at the say screen, you'll find that there's a variable called who.
In this case, who stands for the name of the character speaking "Char". But we don't want that, because it may change for cases when you re-set a character's name. Two characters may have the same name too, and yet they may have different dialogue boxes, therefore we should avoid using that. So what we actually want is chara1, which won't ever change throughout your game, and that variable is stored in _last_say_who
So now that we have the unique variable that differs per character. We go ahead and set that in the Say Screen.
Code: Select all
screen say(who, what):
style_prefix "say"
window:
id "window"
if who is not None:
window:
id "namebox"
style "namebox"
text who id "who"
if _last_say_who=="chara1":
#your code to change the background of the window
text what id "what"
We will use this to set the background of the window based on the variable friendship that you have made per capturable character. In this case, I set friendship_char1 as the variable that decides which image to use. And with that, here's the final ConditionSwitch():
Code: Select all
screen say(who, what):
style_prefix "say"
window:
id "window"
if who is not None:
window:
id "namebox"
style "namebox"
text who id "who"
if _last_say_who=="chara1":
background ConditionSwitch(
"friendship_char1 == 0", "gui/frame_chara1_4.png",
"friendship_char1 <= 5 and friendship_char1 >0", "gui/frame_chara1_3.png",
"friendship_char1 <= 10 and friendship_char1 >5", "gui/frame_chara1_2.png",
"friendship_char1 <= 15 and friendship_char1 >10", "gui/frame_chara1_1.png",
"True", "gui/frame.png")
text what id "what"
Goodluck with your project!
Anime sprite commissions $30 per character: viewtopic.php?f=62&t=60703&p=536689#p536689
Re: Variable Dialog Box
Ok wow so I made that soooo overly complicated no wonder it wouldn't work
Thank you so much that was way more than I was expecting
My wall and my forehead thank you also... mouse and keyboard probably should also
Joking aside thank you
Thank you so much that was way more than I was expecting
My wall and my forehead thank you also... mouse and keyboard probably should also
Joking aside thank you
-
Xiael
- Regular
- Posts: 31
- Joined: Thu Aug 06, 2020 9:13 am
- itch: Xiael
- Discord: message me first here
- Contact:
Re: Variable Dialog Box
No problem! :> Glad to help
Don't forget to mark as [Solved] if you have no more clarifications~
Anime sprite commissions $30 per character: viewtopic.php?f=62&t=60703&p=536689#p536689
Who is online
Users browsing this forum: Google [Bot]