I've made a dress-up screen where you can choose a custom look for your character.
Here's the dress-up screen:
Code: Select all
init python:
dressup_show = False
dressup_button_show = False
skin, glasses, dress, hair = 1, 2, 2, 2 # default dressup items
skin_styles_num, glasses_styles_num, dress_styles_num, hair_styles_num = 2, 3, 4, 2 # number of styles (files) for each dressup item
def draw_girl(st, at):# same thing as above, just scaled and positioned for the sideimage; there's probably more elegant solution than this...
return LiveComposite(
(0, 0),
(0, 0), im.FactorScale("base.png", 1.5, 1.5),
(80, 468), im.FactorScale("skin%d.png"%skin, 1.5, 1.5),
(80, 468), im.FactorScale("dress%d.png"%dress, 1.5, 1.5),
(80, 468), im.FactorScale("hair%d.png"%hair, 1.5, 1.5),
(80, 468), im.FactorScale("glasses%d.png"%glasses, 1.5, 1.5)
),.1
init:
image girl = DynamicDisplayable(draw_girl) # using DynamicDisplayable ensures that any changes are visible immedietly
$ girl = Character('girl', color="#700a1b", show_two_window=True,show_side_image=DynamicDisplayable(draw_girl_side))
$ persistent.girl == girl
$ renpy.save_persistent()
#########################################################################
screen dressup_button: # a button to call the dressup game
if dressup_button_show and not dressup_show:
imagemap:
idle "dressstart1.png"
hover "dressstart2.png"
hotspot (282, 970, 148, 156) action SetVariable("dressup_show", True)
#########################################################################
screen dressup:
if dressup_show:
add "girl" xalign 0 yalign 0 xpos 0
python:
hair_n = hair + 1 # if next hair is chosen
hair_p = hair - 1 # if previous hair is chosen
if hair_p < 1: # making sure we don't get out of index range (index 0 is not allowed)
hair_p = hair_styles_num
if hair_n > hair_styles_num: # making sure we don't get out of index range (index musn't be bigger than hair_styles_num)
hair_n = 1
glasses_n = glasses + 1
glasses_p = glasses - 1
if glasses_p < 1:
glasses_p = glasses_styles_num
if glasses_n > glasses_styles_num:
glasses_n = 1
dress_n = dress + 1
dress_p = dress - 1
if dress_p < 1:
dress_p = dress_styles_num
if dress_n > dress_styles_num:
dress_n = 1
skin_n = skin + 1
skin_p = skin - 1
if skin_p < 1:
skin_p = skin_styles_num
if skin_n > skin_styles_num:
skin_n = 1
y = 90
ui.imagebutton("arrowL.png", "arrowL.png", clicked=SetVariable("hair", hair_p), ypos=y, xpos=10)
y += 180
ui.imagebutton("arrowL.png", "arrowL.png", clicked=SetVariable("glasses", glasses_p), ypos=y, xpos=10)
y += 180
ui.imagebutton("arrowL.png", "arrowL.png", clicked=SetVariable("dress", dress_p), ypos=90, xpos=190)
y += 180
ui.imagebutton("arrowL.png", "arrowL.png", clicked=SetVariable("skin", skin_p), ypos=270, xpos=190)
textbutton ("Done") action ShowMenu ("main_menu")
I'm having trouble making this custom character remembered after you close and reopen the game. Right now, I'll put a red dress on the customizable characters, and when I'm done dressing her, she will appear on the menu in the red dress as I want, but after I press play on the game or exit the game, the character shown on the menu will go back to a default gray dress, as if she were never customized in the first place.
The custom character is shown on the menu, so you can't save the progress after dressing her.
I'm mainly trying to define this character image "girl" by adding persistent.data in order to finalize how the player chooses to dress their avatar/pov character when closing the game and reopening.
This is the part I'm trying to work on:
Code: Select all
init:
image girl = DynamicDisplayable(draw_girl) # using DynamicDisplayable ensures that any changes are visible immedietly
$ girl = Character('girl', color="#700a1b", show_two_window=True,show_side_image=DynamicDisplayable(draw_girl_side))
$ persistent.girl == girl
$ renpy.save_persistent()