[SOLVED] Define Images After Initialization?

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
WhiteFog
Newbie
Posts: 13
Joined: Mon Jul 01, 2019 11:40 pm
Contact:

[SOLVED] Define Images After Initialization?

#1 Post by WhiteFog »

There may also be an easier way to do this, but this is the route my brain took.

So the opening of the game goes like so-

Code: Select all

label start:
    "Choose your appearance!"
    call screen character_select
Then said screen look like so...

Code: Select all

screen character_select:
    grid 5 2:
        imagebutton auto "MC/01MCNeutral1Uniform_%s.png" action Confirm('Is this correct?', yes=Return("1"), no=None, confirm_selected=False)
        imagebutton auto "MC/01FemMCNeutral1Uniform_%s.png" action Confirm('Is this correct?', yes=Return(2), no=None, confirm_selected=False)
        imagebutton auto "MC/02MCNeutral1Uniform_%s.png" action Confirm('Is this correct?', yes=Return(3), no=None, confirm_selected=False)
        imagebutton auto "MC/02FemMCNeutral1Uniform_%s.png" action Confirm('Is this correct?', yes=Return(4), no=None, confirm_selected=False)
        imagebutton auto "MC/03MCNeutral1Uniform_%s.png" action Confirm('Is this correct?', yes=Return(5), no=None, confirm_selected=False)

        imagebutton auto "MC/03FemMCNeutral1Uniform_%s.png" action Confirm('Is this correct?', yes=Return(6), no=None, confirm_selected=False)
        imagebutton auto "MC/04MCNeutral1Uniform_%s.png" action Confirm('Is this correct?', yes=Return(7), no=None, confirm_selected=False)
        imagebutton auto "MC/04FemMCNeutral1Uniform_%s.png" action Confirm('Is this correct?', yes=Return(8), no=None, confirm_selected=False)
        imagebutton auto "MC/05MCNeutral1Uniform_%s.png" action Confirm('Is this correct?', yes=Return(9), no=None, confirm_selected=False)
        imagebutton auto "MC/05FemMCNeutral1Uniform_%s.png" action Confirm('Is this correct?', yes=Return(0), no=None, confirm_selected=False)
The whole intro looks like this-

Code: Select all

label start:
    "Choose your appearance!"
    call screen character_select
    $ morgan = _return
    if morgan == 0:
        image mcav = "mc/0av.png"
    elif morgan == "1":
        image mcav = "mc/1av.png"
    elif morgan == 2:
        image mcav = "mc/2av.png"
    elif morgan == 3:
        image mcav = "mc/3av.png"
    elif morgan == 4:
        image mcav = "mc/4av.png"
    elif morgan == 5:
        image mcav = "mc/5av.png"
    elif morgan == 6:
        image mcav = "mc/6av.png"
    elif morgan == 7:
        image mcav = "mc/7av.png"
    elif morgan == 8:
        image mcav = "mc/8av.png"
    elif morgan == 9:
        image mcav = "mc/9av.png"
Unfortunately, and my one guess is that it's because the images are defined at initialization, no matter what I try, my mcav (Main Character Avatar) always ends up as 9av.png.

Obviously this is also spaghetti code and I'm sure there's a neater way to do it, but I would like to know if there's an easier way to simply use the art selected for the avatar. We've got 2 genders with 5 styles each, so having some way to actually show that on screen would be lovely.

Thank you in advance for ideas and clarifications!
Last edited by WhiteFog on Thu Aug 13, 2020 9:34 am, edited 1 time in total.

User avatar
IrinaLazareva
Veteran
Posts: 399
Joined: Wed Jun 08, 2016 1:49 pm
Projects: Legacy
Organization: SunShI
Location: St.Petersburg, Russia
Contact:

Re: Define Images After Initialization?

#2 Post by IrinaLazareva »

Code: Select all

default morgan = 0
image mcav = "mc/[morgan]av.png"

label start:
    "Choose your appearance!"
    call screen character_select
    $ morgan = _return

WhiteFog
Newbie
Posts: 13
Joined: Mon Jul 01, 2019 11:40 pm
Contact:

Re: Define Images After Initialization?

#3 Post by WhiteFog »

I'll be damned. Much easier and it works! Thanks!

Post Reply

Who is online

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