Characters with image attributes: menu and python equivalent

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
goldo
Regular
Posts: 63
Joined: Mon Jan 23, 2017 8:23 am
Contact:

Characters with image attributes: menu and python equivalent

#1 Post by goldo » Thu May 11, 2017 6:14 am

Hi everyone,

Two things have been nagging me for a while about using characters with image attributes. (This is a problem with the side image only; I don't want the character image to be shown in this particular interaction.)

First, it seems using attributes in a menu prompt doesn't work:

Code: Select all

menu:
        e happy "How can I help you?"
        
        "Help with the current screen":
                pass
        "Go back":
                pass
It returns an error:

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/BKhelp.rpy", line 14: expected menuitem
    e happy "How can I help you?"
    ^

Ren'Py Version: Ren'Py 6.99.10.1227

The only workaround I could find if this:

Code: Select all

e happy "{nw}"

menu:
        e "How can I help you?"
        
        "Help with the current screen":
                pass
        "Go back":
                pass
However, in spite of the 'no wait' tag, the effect is very noticeable in game, with the side image appearing briefly by itself before the menu shows. It isn't great.

So Question 1: Is there another way to do this?

Question 2 is more straightforward. What is the python equivalent of say with image attribute? I mean this:

Code: Select all

e happy "Bla bla bla"
I have tried:

Code: Select all

$ renpy.say(e happy, "Bla bla bla")
... and various other things, but it just produces errors. I've looked hard, but I couldn't find any documentation on how side attributes work in python.

Does anyone have answers to those two questions?
Anyway, thanks a lot for reading this far! ^^
Last edited by goldo on Fri May 12, 2017 12:24 am, edited 1 time in total.

User avatar
Saltome
Veteran
Posts: 237
Joined: Sun Oct 26, 2014 1:07 pm
Deviantart: saltome
Contact:

Re: Characters with image attributes: menu and python equiva

#2 Post by Saltome » Thu May 11, 2017 4:46 pm

I don't see why you are overcomplicating this so much. If you wanna show an image on the menu, show the image before the menu then hide it when you are leaving the menu.
Deviant Art: Image

goldo
Regular
Posts: 63
Joined: Mon Jan 23, 2017 8:23 am
Contact:

Re: Characters with image attributes: menu and python equiva

#3 Post by goldo » Fri May 12, 2017 12:21 am

Saltome wrote:I don't see why you are overcomplicating this so much. If you wanna show an image on the menu, show the image before the menu then hide it when you are leaving the menu.
Sorry, I guess my question was unclear. I'm taking about the side image. I don't want the main image shown (otherwise I wouldn't have this problem), just the side image when the character is talking.

User avatar
Saltome
Veteran
Posts: 237
Joined: Sun Oct 26, 2014 1:07 pm
Deviantart: saltome
Contact:

Re: Characters with image attributes: menu and python equiva

#4 Post by Saltome » Fri May 12, 2017 10:51 am

Hmm, I assume you don't really need to be able to change the menu side image once it's shown. Why don't you take the simple way out and define a new character, specifically for the menu, and link it to the side image you want to be shown?

Also, in your solution there really is a minute dilay between using the say statement and the appearance of the menu items. But it's pretty hard to notice. Unless you're lagging maybe? Might be a worthwhile solution.

Now that I'm looking into it, seems to be possible to change the image associated with existing characters, this way you can change it to a different image that is specifically for the menu.
Still not sure how to change the exact image being shown though.

Code: Select all

image side eileen_menu = "menu_happy.png"
$ e.image_tag = "eileen_menu" # this makes it so instead of the eileen images the character uses eileen_menu images. In this case you only have one image so you don't need to specify it to the menu
I think I'm close but I can't quite figure out how to tell it which attribute I want the image to have.
Deviant Art: Image

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1883
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Characters with image attributes: menu and python equiva

#5 Post by Ocelot » Fri May 12, 2017 1:09 pm

One situation, where defining new character would not work properly:

Code: Select all

image eileen formal_dress = #...
image eileen formal_dress happy = #...
image eileen swimsuit = #...
image eileen swimsuit happy = #...

# . . .
if current_outfit == 'swimsuit':
    show eileen swimsuit
else:
    eileen formal_dress 
# much later
e happy 'Some text' # Will correctly show eileen formal_dress happy  OR eileen swimsuit happy  depending on previously shown image
< < insert Rick Cook quote here > >

goldo
Regular
Posts: 63
Joined: Mon Jan 23, 2017 8:23 am
Contact:

Re: Characters with image attributes: menu and python equiva

#6 Post by goldo » Sun May 14, 2017 3:10 am

Saltome wrote:Hmm, I assume you don't really need to be able to change the menu side image once it's shown. Why don't you take the simple way out and define a new character, specifically for the menu, and link it to the side image you want to be shown?

Also, in your solution there really is a minute dilay between using the say statement and the appearance of the menu items. But it's pretty hard to notice. Unless you're lagging maybe? Might be a worthwhile solution.

Now that I'm looking into it, seems to be possible to change the image associated with existing characters, this way you can change it to a different image that is specifically for the menu.
Still not sure how to change the exact image being shown though.

Code: Select all

image side eileen_menu = "menu_happy.png"
$ e.image_tag = "eileen_menu" # this makes it so instead of the eileen images the character uses eileen_menu images. In this case you only have one image so you don't need to specify it to the menu
I think I'm close but I can't quite figure out how to tell it which attribute I want the image to have.
Mmh, that's an interesting solution, but it isn't suited to the game I'm working on, as I will be using various facial expressions on various characters, and it will get to be a bit much if I have to define a different character for each facial expression (although thankfully I don't have the problem Ocelot is talking about).

I guess I'll stick to the method I use now, maybe if I predicted the image it would work smoother?

User avatar
Saltome
Veteran
Posts: 237
Joined: Sun Oct 26, 2014 1:07 pm
Deviantart: saltome
Contact:

Re: Characters with image attributes: menu and python equiva

#7 Post by Saltome » Sun May 14, 2017 9:01 am

Hmm... I may keep looking into this. But for now you can try this approach.
https://www.renpy.org/wiki/renpy/doc/co ... ide_Images
Alternatively you can opt for a basic custom screen to serve as a menu. Should be easier to get the flexibility you want.
Deviant Art: Image

goldo
Regular
Posts: 63
Joined: Mon Jan 23, 2017 8:23 am
Contact:

Re: Characters with image attributes: menu and python equiva

#8 Post by goldo » Mon May 15, 2017 11:23 pm

Saltome wrote:Hmm... I may keep looking into this. But for now you can try this approach.
https://www.renpy.org/wiki/renpy/doc/co ... ide_Images
Alternatively you can opt for a basic custom screen to serve as a menu. Should be easier to get the flexibility you want.
Nice one, thanks.

Post Reply

Who is online

Users browsing this forum: Bing [Bot]