Show stats of the current character talking

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
User avatar
HydraHenker
Newbie
Posts: 7
Joined: Thu Oct 25, 2018 12:53 pm
Projects: Time Loop Hunter
Contact:

Show stats of the current character talking

#1 Post by HydraHenker »

Ok, so this is what I want to achieve:
I want to show some stats of all the characters that speak to the MC in the current scene.

This is how I did it:
I defined the Sprite and side images with LiveComposite and DynamicDisplayable

Code: Select all

    image Alice Normal = LiveComposite(
                                (692, 1080),
                                (0, 0), "Characters/Alice/[ali.state]_Alice_Normal.png",
                                (1150, 100), DynamicDisplayable(composite_char_attr_show_new, name="Alice"),
                                )
The side image

Code: Select all

    image side Alice Normal = LiveComposite(
                                (300, 300),
                                (0, 0), "Characters/Alice/Side/[ali.state]_Alice_Side_Normal.png",
                                (1150, 100), DynamicDisplayable(composite_char_attr_show_new, name="Alice"),
                                )
And an image that shows the face of the character plus 4 stats in like a flower thingy.

Code: Select all

    image Alice_Stats = LiveComposite(
                                (128, 995),
                                (0, 0), "gui/icons/50/Cloud2.png",
                                (40, 40), "gui/icons/50/Alice.png",
                                (20, 26), DynamicDisplayable(composite_char_attr_level, char="ali", attr="stat1", attrlvl="stat1_level") ,
                                (73, 26), DynamicDisplayable(composite_char_attr_level, char="ali", attr="stat2", attrlvl="stat2_level"),
                                (20, 69), DynamicDisplayable(composite_char_attr_level, char="ali", attr="stat3", attrlvl="stat3_level"),
                                (73, 69), DynamicDisplayable(composite_char_attr_level, char="ali", attr="stat4", attrlvl="stat4_level"),
                                )
This is the function that determines to show or not to show the flower:

Code: Select all


    def composite_char_attr_show_new(st,at,name):
        current_tag = renpy.get_say_image_tag()
            if name ==current_tag:
                show_stat_flower(name)

        return Null(), None

In summary:
I check the if renpy.get_say_image_tag() is equal to the character and if it is, I show the flower with stats
And this works... kind of...

The problem is:
I have scenes that are the same scene but you can visit them with one or two characters
So one character is there and there is a conditional for the other character to be or not be there.
And here is when the problem comes, the is something that seems to be reading ahead of the lines in renpy (maybe some cache?) that ignores all conditionals and triggers the  DynamicDisplayable with renpy.get_say_image_tag(). So now I have two stat flowers showing when there is only one character on the current scene.

Example:
Image


My question:
What's the correct way to do this?

Thanks,
Cheers!
Image

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]