How to make certain image appear based user character select

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
amaturemanga
Regular
Posts: 97
Joined: Sun Mar 08, 2015 6:55 pm
Deviantart: amaturemanga
Skype: amature.manga
Contact:

How to make certain image appear based user character select

#1 Post by amaturemanga »

Hey so i have 6 different version of the same image and in my game i have character customization and i want one version of that image to appear based on what the player did during the character customization. And im confused on how to go about it, any ideas here is character customization code split up

cc_screen

Code: Select all

define character_img = "base.png"
   

screen character_customization_screen:
    modal True
    tag menu

    # The main menu buttons.
    frame:
        xalign .7
        yalign .5

        has vbox
        
        hbox:
            vbox:
                $ ui.text("Hair styles", size= 23,color="#496682")
                textbutton _("hairstyle1") action [ SetVariable("hairstyle1","hair1.png")]
                textbutton _("hairstyle2") action [ SetVariable("hairstyle2", "hair2.png")]
                textbutton _("hairstyle3") action [ SetVariable( "hairstyle3","hair3.png")]
                textbutton _("hairstyle4") action [ SetVariable( "hairstyle4","hair4.png")]
                textbutton _("hairstyle5") action [ SetVariable( "hairstyle5","hair5.png")]
                textbutton _("hairstyle6") action [ SetVariable( "hairstyle6","hair6.png")]
                
            
                   
           
        
    add character_img:
        pos (-60,81)
cc_settings

Code: Select all

init:
    ## CHARACTER APPEARANCE ##
    $ body = "base"
    $ hairstyle1 = "hair1"
    $ hairstyle2 = "hair2"
    $ hairstyle3 = "hair3"
    $ hairstyle4 = "hair4"
    $ hairstyle5 = "hair5"
    $ hairstyle6 = "hair6"
character_script

Code: Select all

init python:
    hair = 1
    def draw_character(st, at): # combine the dressup items into one displayable
        return LiveComposite(
            (361, 702), # image size
            (0, 0), "base.png",
            (0, 0), "hair%d.png"%hair,
            ),.1

init:
    image character = DynamicDisplayable(draw_character)

screen character_customization_screen:
    modal True
    tag menu

    frame:
        xalign .7
        yalign .5

        has vbox
        
        hbox:
            vbox:
                $ ui.text("Hair styles", size= 23,color="#496682")
                textbutton _("hairstyle1") action [ SetVariable("hair", 1)]
                textbutton _("hairstyle2") action [ SetVariable("hair", 2)]
                textbutton _("hairstyle3") action [ SetVariable( "hair", 3)]
                textbutton _("hairstyle4") action [ SetVariable( "hair", 4)]
                textbutton _("hairstyle5") action [ SetVariable( "hair", 5)]
                textbutton _("hairstyle6") action [ SetVariable( "hair", 6)]
                textbutton "OK" action Return() xpos 100 ypos 100
                
    add "character":
        pos (-60,81)
  
        
    

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: How to make certain image appear based user character se

#2 Post by Alex »

It looks like code in character_script should do the trick (choose hairstyle and press Ok to see changes).
Not quite understand why do you have two versions of character_customization_screen...
Also, try to set hair variable not in init block but using default statement.

User avatar
amaturemanga
Regular
Posts: 97
Joined: Sun Mar 08, 2015 6:55 pm
Deviantart: amaturemanga
Skype: amature.manga
Contact:

Re: How to make certain image appear based user character se

#3 Post by amaturemanga »

Alex wrote:It looks like code in character_script should do the trick (choose hairstyle and press Ok to see changes).
Not quite understand why do you have two versions of character_customization_screen...
Also, try to set hair variable not in init block but using default statement.
no no that's not what im trying to do the character customization works fine i have 6 different versions of the same background image what i want is for let's say the user selects hairstyle 1 i want version 1 of the background image to show during a scene of the game which is about 5 minutes into the game

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: How to make certain image appear based user character se

#4 Post by Alex »

Well, then try to make your bg image to be the dynamic one (the same as character image) based on value of "hair" variable.

User avatar
amaturemanga
Regular
Posts: 97
Joined: Sun Mar 08, 2015 6:55 pm
Deviantart: amaturemanga
Skype: amature.manga
Contact:

Re: How to make certain image appear based user character se

#5 Post by amaturemanga »

Alex wrote:Well, then try to make your bg image to be the dynamic one (the same as character image) based on value of "hair" variable.
so like a conditionswitch?

Code: Select all

 image example = ConditionSwitch(
                   "hairstyle1", "background1.png",
                   "hairstyle2", "background2.png",
                   "hairstyle3", "background3.png",
                   "hairstyle4", "background4.png",
                   "hairstyle5", "background5.png",
                   "hairstyle6", "background6.png")
do you think something like this would work?

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: How to make certain image appear based user character se

#6 Post by Alex »

It definitely should work (if you'll code it correct)...))
Choose the right variable (I assum it would be hair) and check this examples:
https://www.renpy.org/doc/html/displaya ... splayables
viewtopic.php?f=51&t=19063

Post Reply

Who is online

Users browsing this forum: piinkpuddiin