(SOLVED) Showing Characters?

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.
Post Reply
Message
Author
RoboKnight
Newbie
Posts: 19
Joined: Sun Feb 18, 2018 6:12 pm
Contact:

(SOLVED) Showing Characters?

#1 Post by RoboKnight »

I really know this is a completely noobish question, but I can't find this anywhere. There has got to be a better way to show characters/change their expressions in a better way than

Code: Select all

show Player Happy

#P is for Player
P "I am happy."

show NPC sad

NPC "I am sad."

show Player Concerned

P "Why are you sad?"
This is just an example but I can't seriously imagine people who write tens of thousands of lines of story text keep adding "show (image)" lines in between every sentence. Is there not a way to show characters/character expressions on the same line as when they're talking?
Last edited by RoboKnight on Tue Feb 20, 2018 3:32 am, edited 3 times in total.

User avatar
Draziya
Regular
Posts: 70
Joined: Sun Nov 26, 2017 8:50 am
Completed: this was for you. [NaNoRenO 19], Acetylene [AceJam19], Ah!! My Roommate is a Succubus Hellbent on World [MonJam 18], I Don't Have A Clue [QRMJam 18], Cautionary Tale [NaNoRenO 18], OP Dodge Cross [GGJ 18], Acetone [AceJam 18]
Projects: I'm a love interest in my childhood friend's reverse harem!!
Organization: Watercress
itch: Drazillion
Contact:

Re: Showing Characters?

#2 Post by Draziya »

There is! It's explained here: https://www.renpy.org/doc/html/dialogue ... attributes

Basically you define the character tag when you define the character, and once you've done that you can show images tagged with that character next to your dialogue.

So with your example, if you defined Player with:

Code: Select all

define p = Character("Player", image="player")
You could then do this:

Code: Select all

p happy "I am happy."
Image

RoboKnight
Newbie
Posts: 19
Joined: Sun Feb 18, 2018 6:12 pm
Contact:

Re: Showing Characters?

#3 Post by RoboKnight »

YES MY LORD AND SAVIOR

Thank you!! This helps so much!

RoboKnight
Newbie
Posts: 19
Joined: Sun Feb 18, 2018 6:12 pm
Contact:

Re: Showing Characters?

#4 Post by RoboKnight »

Draziya wrote: Tue Feb 20, 2018 1:06 am There is! It's explained here: https://www.renpy.org/doc/html/dialogue ... attributes

Basically you define the character tag when you define the character, and once you've done that you can show images tagged with that character next to your dialogue.

So with your example, if you defined Player with:

Code: Select all

define p = Character("Player", image="player")
You could then do this:

Code: Select all

p happy "I am happy."
I really hate to come back like this, but it's not working. This my actual code, with the non-important stuff excluded for simplicity:

Code: Select all

image bg computer lab = im.Scale("bg computer lab.png", 1280, 720)
image Bd Sprite = "Brad Sprite.png"
define Bd = Character('Brad', color="#8A8A8A", image="Bd Sprite")

label start:
     scene bg computer lab
     
     Bd Sprite "test"
I'm only using one image per character because they're all 8 bit. All that happens with this code is that the character, Brad, says "test" with his name in the Namebox as usual, but no image for him appears.

User avatar
Draziya
Regular
Posts: 70
Joined: Sun Nov 26, 2017 8:50 am
Completed: this was for you. [NaNoRenO 19], Acetylene [AceJam19], Ah!! My Roommate is a Succubus Hellbent on World [MonJam 18], I Don't Have A Clue [QRMJam 18], Cautionary Tale [NaNoRenO 18], OP Dodge Cross [GGJ 18], Acetone [AceJam 18]
Projects: I'm a love interest in my childhood friend's reverse harem!!
Organization: Watercress
itch: Drazillion
Contact:

Re: Showing Characters?

#5 Post by Draziya »

An unfortunate thing about this method is that for the first time a character shows up in a scene, you still have to use the show statement.
Image

RoboKnight
Newbie
Posts: 19
Joined: Sun Feb 18, 2018 6:12 pm
Contact:

Re: Showing Characters?

#6 Post by RoboKnight »

Draziya wrote: Tue Feb 20, 2018 2:30 am An unfortunate thing about this method is that for the first time a character shows up in a scene, you still have to use the show statement.
I threw this in after the scene of the code I wrote earlier:

Code: Select all

show Bd Sprite
    Bd "hi"
    hide Bd Sprite
    show P Sprite
    P "also hi"
    hide P Sprite
    Bd Sprite "test"
And when I get to Brad's sprite (Bd Sprite) and I still get no image...

User avatar
Draziya
Regular
Posts: 70
Joined: Sun Nov 26, 2017 8:50 am
Completed: this was for you. [NaNoRenO 19], Acetylene [AceJam19], Ah!! My Roommate is a Succubus Hellbent on World [MonJam 18], I Don't Have A Clue [QRMJam 18], Cautionary Tale [NaNoRenO 18], OP Dodge Cross [GGJ 18], Acetone [AceJam 18]
Projects: I'm a love interest in my childhood friend's reverse harem!!
Organization: Watercress
itch: Drazillion
Contact:

Re: Showing Characters?

#7 Post by Draziya »

Okay, I've identified some problems with your code.

Firstly, you used hide Bd Sprite before you tried out using this method. Hide removes the sprite shown with Show. You need to use Show again.

Code: Select all

    show Bd Sprite
    Bd "hi"
    hide Bd Sprite
    show P Sprite
    P "also hi"
    hide P Sprite
    show Bd Sprite
    Bd Sprite "test"
Secondly image tags (which I mistakenly called the character tag before, sorry about that!) are the first name of an image. In the case of the Bd Sprite image, only Bd is the image tag.

So instead of:

Code: Select all

define Bd = Character('Brad', color="#8A8A8A", image="Bd Sprite")
You need to use:

Code: Select all

define Bd = Character('Brad', color="#8A8A8A", image="Bd")
Of course, if you're showing one image of a character, how can you tell that this is working? To test this out, I had a second sprite called "Bd Sprite Happy" as well.

This is what I did to make the code work:

Code: Select all

label start:
     scene bg computer lab

     show Bd Sprite
     Bd "test"
     Bd Sprite Happy "testtest!"
Image

RoboKnight
Newbie
Posts: 19
Joined: Sun Feb 18, 2018 6:12 pm
Contact:

Re: Showing Characters?

#8 Post by RoboKnight »

Oh, okay I see how this works now.
Thank you for taking the time for this!

Post Reply

Who is online

Users browsing this forum: Google [Bot]