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.
-
hapciupalit
- Regular
- Posts: 52
- Joined: Tue Nov 13, 2018 6:00 am
-
Contact:
#1
Post
by hapciupalit » Wed Oct 21, 2020 8:30 am
So I've been trying to customise the say screen to allow different types of text. Something like this:
Code: Select all
screen say(who, what, type):
style_prefix "say"
window:
id "window"
if who is not None:
window:
style "namebox"
if type == "think":
text who id "who" color "#fafafa" size 10
elif type == "yell":
text who id "who" size 20
else:
text who id "who"
text what id "what"
Is it possible use something like this or maybe instead of those if type to have more screens types of say? But not sure how I'll use them beside:
Code: Select all
screen say_think(who, what):
style_prefix "say"
window:
id "window"
if who is not None:
window:
style "namebox"
text who id "who" color "#fafafa" size 10
text what id "what" color "#fafafa" size 10
show say_think("name", "Hello world!", "yell")
hide say_think
This approach I don't like because there is too much to write, I was hoping for a solution like:
Any idea is good.
-
hell_oh_world
- Miko-Class Veteran
- Posts: 777
- Joined: Fri Jul 12, 2019 5:21 am
- Projects: The Button Man
- Organization: NILA
- Github: hell-oh-world
- Location: Philippines
-
Contact:
#2
Post
by hell_oh_world » Wed Oct 21, 2020 10:22 am
I think you can simply do this without changing anything under the say screen, and just doing this...
Code: Select all
define yell = dict(
who_color="#f00",
who_font="some_font.ttf",
# what_color="#0f0" # you can also pass styles for the what statement, just prefix whatever you want to pass with who/what/window
)
label start:
"normal"
"yelling" (**yell)
another way maybe is to create multiple characters for your character for the different styles...
Code: Select all
define mc = Character("mc", who_color="#fff", what_color="#f00")
define mc_yelling = mc.copy(who_color="#0f0") # sets the who_color to green for the yelling but leaves the what color to red as stated above...
label start:
mc "normal"
mc_yelling "yelling"
-
hapciupalit
- Regular
- Posts: 52
- Joined: Tue Nov 13, 2018 6:00 am
-
Contact:
#3
Post
by hapciupalit » Wed Oct 21, 2020 10:45 am
hell_oh_world wrote: ↑Wed Oct 21, 2020 10:22 am
I think you can simply do this without changing anything under the say screen, and just doing this...
Code: Select all
define yell = dict(
who_color="#f00",
who_font="some_font.ttf",
# what_color="#0f0" # you can also pass styles for the what statement, just prefix whatever you want to pass with who/what/window
)
label start:
"normal"
"yelling" (**yell)
another way maybe is to create multiple characters for your character for the different styles...
Code: Select all
define mc = Character("mc", who_color="#fff", what_color="#f00")
define mc_yelling = mc.copy(who_color="#0f0") # sets the who_color to green for the yelling but leaves the what color to red as stated above...
label start:
mc "normal"
mc_yelling "yelling"
This is perfect! Thank you very much!
-
hapciupalit
- Regular
- Posts: 52
- Joined: Tue Nov 13, 2018 6:00 am
-
Contact:
#4
Post
by hapciupalit » Thu Oct 22, 2020 5:44 am
hell_oh_world wrote: ↑Wed Oct 21, 2020 10:22 am
I think you can simply do this without changing anything under the say screen, and just doing this...
Code: Select all
define yell = dict(
who_color="#f00",
who_font="some_font.ttf",
# what_color="#0f0" # you can also pass styles for the what statement, just prefix whatever you want to pass with who/what/window
)
label start:
"normal"
"yelling" (**yell)
[/code]
I got one more question. I have decided to use this approach, however now I'm strugling with something else. At first I was thinking that when the npc yells it's going to be uppercase, when he is thinking another color and italic text, however the designer have another idea and was wondering if there is an easy way to achieve this.
He wants something like this. So is there a way to expand that dict and the say screen to have something similar?
I've been trying like this, but my python knowledge got the best of me and I'm a bit stuck.
Code: Select all
define thinking = dict (
emo = "*thinking*",
what_color = "#B6B6B6",
what_italic = True
)
screen say(who, what, *emo):
style_prefix "say"
window:
id "window"
if who is not None:
window:
style "namebox"
text who id "who"
if emo :
text emo
text what id "what"
But it crashes. Am I doing something wrong?
-
Imperf3kt
- Lemma-Class Veteran
- Posts: 3636
- Joined: Mon Dec 14, 2015 5:05 am
- Location: Your monitor
-
Contact:
#5
Post
by Imperf3kt » Thu Oct 22, 2020 5:54 am
do you mean the two different text sizes in one dialogue screen?
use text tags
Code: Select all
npc "{size=30}This is size 30 text, {/size} and this is {size=50}size 50{/size} text."
To have it as you've displayed there, something like this should work. (numbers made up, adjust as necessary)
Code: Select all
npc "{size=20}\"Yelling\"{/size}\n\nLorem ipsum dolor sit amet..."
Or this
Code: Select all
npc """
{size=20}Yelling{/size}
Lorem ipsum dolor sit amet..."""
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project:
GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
-
hell_oh_world
- Miko-Class Veteran
- Posts: 777
- Joined: Fri Jul 12, 2019 5:21 am
- Projects: The Button Man
- Organization: NILA
- Github: hell-oh-world
- Location: Philippines
-
Contact:
#6
Post
by hell_oh_world » Thu Oct 22, 2020 9:24 am
well, it's getting a bit complicated what you want, but i can suggest a workaround, though not really sure if it is the best way, but it works.
first is to remove the
*emo in your code.
then replace the condition within the say screen as something like...
Code: Select all
$ emo = _last_say_kwargs.get("emo") # emo since this is what you named the value in your thinking dict...
if emo:
text emo
Isn't that Brian from RoyalCandy's game? Maybe just a coincidence?
then just past it normally,
(**thinking)...
-
hapciupalit
- Regular
- Posts: 52
- Joined: Tue Nov 13, 2018 6:00 am
-
Contact:
#7
Post
by hapciupalit » Thu Oct 22, 2020 10:53 am
hell_oh_world wrote: ↑Thu Oct 22, 2020 9:24 am
well, it's getting a bit complicated what you want, but i can suggest a workaround, though not really sure if it is the best way, but it works.
first is to remove the
*emo in your code.
then replace the condition within the say screen as something like...
Code: Select all
$ emo = _last_say_kwargs.get("emo") # emo since this is what you named the value in your thinking dict...
if emo:
text emo
Isn't that Brian from RoyalCandy's game? Maybe just a coincidence?
then just past it normally,
(**thinking)...
This is working like charm. Thank you very much!
-
hapciupalit
- Regular
- Posts: 52
- Joined: Tue Nov 13, 2018 6:00 am
-
Contact:
#8
Post
by hapciupalit » Thu Oct 22, 2020 10:58 am
Imperf3kt wrote: ↑Thu Oct 22, 2020 5:54 am
do you mean the two different text sizes in one dialogue screen?
use text tags
Code: Select all
npc "{size=30}This is size 30 text, {/size} and this is {size=50}size 50{/size} text."
To have it as you've displayed there, something like this should work. (numbers made up, adjust as necessary)
Code: Select all
npc "{size=20}\"Yelling\"{/size}\n\nLorem ipsum dolor sit amet..."
Or this
Code: Select all
npc """
{size=20}Yelling{/size}
Lorem ipsum dolor sit amet..."""
[/quote]
This is the approach I'm currently using however I wanted to be more consistent and create some rules and make the writing more easily. So instead of all the
[code]
{size=..}...{/size}\n ... {i}...{/i}" and so on...
I just wanted to have something like :
But with hell_oh_wolrd's approach it's worrking really nice, it's more heavy on the python code, but now when I write text for different emotions I just do:
Code: Select all
npc "Something" (**yell)
npc "I'm whispering something here" (**whisper)
-
hapciupalit
- Regular
- Posts: 52
- Joined: Tue Nov 13, 2018 6:00 am
-
Contact:
#9
Post
by hapciupalit » Fri Nov 20, 2020 6:31 am
hell_oh_world wrote: ↑Wed Oct 21, 2020 10:22 am
I think you can simply do this without changing anything under the say screen, and just doing this...
Code: Select all
define yell = dict(
who_color="#f00",
who_font="some_font.ttf",
# what_color="#0f0" # you can also pass styles for the what statement, just prefix whatever you want to pass with who/what/window
)
label start:
"normal"
"yelling" (**yell)
another way maybe is to create multiple characters for your character for the different styles...
Code: Select all
define mc = Character("mc", who_color="#fff", what_color="#f00")
define mc_yelling = mc.copy(who_color="#0f0") # sets the who_color to green for the yelling but leaves the what color to red as stated above...
label start:
mc "normal"
mc_yelling "yelling"
I discovered a bug I haven't realised at first, because I was testing this in a simple project. But now that I have integrated everything in my game something is wrong.
Whenever I use (**thinking) or something, the npc name turns to "renpy.object.Sentinel". The thing that could affect is my Character class.
Code: Select all
class Player(ADVCharacter):
def __init__(self, name="Justin", **kwargs):
super(Player, self).__init__(name,**kwargs)
self.name = name
#some method goes here
default justin = Player()
And now if I say something like this:
Code: Select all
justin "Say something"
justin "Say something loud." (**loud)
Instead of seeing his name in the screen I see "renpy.object.Sentinel".
Do you have any idea what am I doing wrong?
I'm sure that the methods in the Player class does not affect this because I have deleted everything there to test and it was still the same.
-
hell_oh_world
- Miko-Class Veteran
- Posts: 777
- Joined: Fri Jul 12, 2019 5:21 am
- Projects: The Button Man
- Organization: NILA
- Github: hell-oh-world
- Location: Philippines
-
Contact:
#10
Post
by hell_oh_world » Fri Nov 20, 2020 12:49 pm
in your code, you actually passed already the name in your parent class' constructor in this line.
Code: Select all
super(Player, self).__init__(name,**kwargs)
so no need to do this. just remove this line.
tbh, I don't know why it's happening as I am not that *very* knowledgeable about how renpy works behind the curtains. but removing that line should solve the issue.
-
hapciupalit
- Regular
- Posts: 52
- Joined: Tue Nov 13, 2018 6:00 am
-
Contact:
#11
Post
by hapciupalit » Sat Nov 21, 2020 5:23 am
hell_oh_world wrote: ↑Fri Nov 20, 2020 12:49 pm
in your code, you actually passed already the name in your parent class' constructor in this line.
Code: Select all
super(Player, self).__init__(name,**kwargs)
so no need to do this. just remove this line.
tbh, I don't know why it's happening as I am not that *very* knowledgeable about how renpy works behind the curtains. but removing that line should solve the issue.
You're a gem. Thank you very much! It works perfectly now!
Users browsing this forum: Google [Bot]