Aliasing images

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
docclox
Newbie
Posts: 20
Joined: Thu Oct 12, 2017 6:26 am
Contact:

Aliasing images

#1 Post by docclox » Sat Oct 21, 2017 2:29 am

In the interests of making work for myself, I'm allowing the player to choose their gender, and then pick a face. (Well, I only have one face for each at the moment, but soon!)

Anyway, I have a lot of images kicking around and I need to check gender each time I want to manipulate one. That's only going to get worse when I offer multiple mugshots. So I'd like to set up an alias so I have one name or variable that for each type of image (sidebar, figure, mugshot, etc...) and just point them at the images chosen by the player. I saw this was doable from the documentation somewhere (or it might have been the pre-release tutorial code) but I can't seem to make it work.

What I'm doing at the moment works, but it's not going to scale well, so I was wondering if anyone could give me a couple of pointers. Here's some of my code:

Code: Select all

#
#   pick a picture for the player - I want some degree of customisation here, long term
#   for now we'll just do one male, one female
#
    d "All right. [player.name], now we need a mugshot."
    hide detective
    if player.gender == "M":
        show mpc1_mugshot at Position(yalign = 0.2)
        $ p = Character(player.name,  color="#008000", image="mpc1")
        d "Does that look like you?"
        show mpc1_mugshot at Position(yalign = 0.2):
           linear 0.3 xalign 0.0
    else:
        show fpc1_mugshot at Position(yalign = 0.2)
        $ p = Character(player.name,  color="#008000", image="fpc1")
        d "Does that look like you?"
        show fpc1_mugshot at Position(yalign = 0.2):
           linear 0.3 xalign 0.0

    menu:
        "Yeah, that's me":
            p "Looks close enough, I suppose."
            d "Cool! I'll get that entered into the official record."
        "It kind of looks like me. A bit. If you don't look at it":
            p "It kind of looks like me. A bit. If you don't look at it."
            d "I'll take that as a \"yes\", wiseass!"
        "That's nothing like me!":
            p "That's nothing like me!"
            d "Too bad, seeing as it's the only one we got. It'll just have to do."
            d "We can maybe get a better likeness a little later on"
#
#   I could probably roll this into selection, but I want to offer multiple mugshots later on
#
    if player.gender == "M":
        hide mpc1_mugshot 
    else:
        hide fpc1_mugshot 
Any ideas?

Post Reply

Who is online

Users browsing this forum: Triority