Character Creator Crashing

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
DewyNebula
Newbie
Posts: 7
Joined: Sun Apr 21, 2024 10:57 am
Contact:

Character Creator Crashing

#1 Post by DewyNebula »

Hello. I recently got into RenPy and started working on a visual novel. I'm working on a character creator where you will choose colors to define other body parts. By that, I mean selecting a "blond" hair color and having the hair and eyelashes match. The option buttons for the eyes or hair limit them only to shape, not to cycle through all the different color options. Although I thought I had it figured out, my game crashed with no error report. I've posted my code below - any help would be appreciated. (Also, I'm aware there is only one hairstyle right now - currently making the asset for the other)

Code: Select all

# Character Creation
label start:

    scene bg creation
    with fade

    default hair = 1
    default eyeshape = 1
    default eyecolor = 1
    default nose = 1
    default lips = 1
    default skin = 1

    layeredimage player:

        # Hairstyle and color
        if hair == 1 and haircolor == 1:
            "\images\cc-hair-wavy-black.png"
        if hair == 1 and haircolor == 2:
            "\images\cc-hair-wavy-blonde.png"
        if hair == 1 and haircolor == 3:
            "\images\cc-hair-wavy-brown.png"
        if hair == 1 and haircolor == 4:
            "\images\cc-hair-wavy-dark-brown.png"
        if hair == 1 and haircolor == 5:
            "\images\cc-hair-wavy-ginger.png"
        if hair == 1 and haircolor == 6:
            "\images\cc-hair-wavy-light-brown.png"

        # Eye shape and color
        if haircolor == 1 and eyeshape == 1:
            "\images\cc-eyeshape-large-black.png"
        if haircolor == 2 and eyeshape == 1:
            "\images\cc-eyeshape-large-blond.png"
        if haircolor == 3 and eyeshape == 1:
            "\images\cc-eyeshape-large-brown.png"
        if haircolor == 4 and eyeshape == 1:
            "\images\cc-eyeshape-large-dark-brown.png"
        if haircolor == 5 and eyeshape == 1:
            "\images\cc-eyeshape-large-ginger.png"
        if haircolor == 6 and eyeshape == 1:
            "\images\cc-eyeshape-large-light-brown.png"
        if haircolor == 1 and eyeshape == 2:
            "\images\cc-eyeshape-small-black.png"
        if haircolor == 2 and eyeshape == 2:
            "\images\cc-eyeshape-small-blond.png"
        if haircolor == 3 and eyeshape == 2:
            "\images\cc-eyeshape-small-brown.png"
        if haircolor == 4 and eyeshape == 2:
            "\images\cc-eyeshape-small-dark-brown.png"
        if haircolor == 5 and eyeshape == 2:
            "\images\cc-eyeshape-small-ginger.png"
        if haircolor == 6 and eyeshape == 2:
            "\images\cc-eyeshape-small-light-brown.png"
        
        # Eye color
        if eyecolor == 1:
            "\images\cc-eyecolor-blue.png"
        if eyecolor == 2:
            "\images\cc-eyecolor-brown.png"
        if eyecolor == 3:
            "\images\cc-eyecolor-dark-brown.png"
        if eyecolor == 4:
            "\images\cc-eyecolor-green.png"
        if eyecolor == 5:
            "\images\cc-eyecolor-grey.png"
        if eyecolor == 6:
            "\images\cc-eyecolor-hazel.png"

        # Nose shape and color
        if skin == 1 and nose == 1:
            "\images\cc-nose-large-brown.png"
        if skin == 2 and nose == 1:
            "\images\cc-nose-large-dark-brown.png"
        if skin == 3 and nose == 1:
            "\images\cc-nose-large-fair.png"
        if skin == 4 and nose == 1:
            "\images\cc-nose-large-medium.png"
        if skin == 5 and nose == 1:
            "\images\cc-nose-large-olive.png"
        if skin == 6 and nose == 1:
            "\images\cc-nose-large-pale.png"
        if skin == 1 and nose == 2:
            "\images\cc-nose-small-brown.png"
        if skin == 2 and nose == 2:
            "\images\cc-nose-small-dark-brown.png"
        if skin == 3 and nose == 2:
            "\images\cc-nose-small-fair.png"
        if skin == 4 and nose == 2:
            "\images\cc-nose-small-medium.png"
        if skin == 5 and nose == 2:
            "\images\cc-nose-small-olive.png"
        if skin == 6 and nose == 2:
            "\images\cc-nose-small-pale.png"

        # Lips shape and color
        if skin == 1 and lips == 1:
            "\images\cc-lips-large-brown.png"
        if skin == 2 and lips == 1:
            "\images\cc-lips-large-dark-brown.png"
        if skin == 3 and lips == 1:
            "\images\cc-nose-large-fair.png"
        if skin == 4 and lips == 1:
            "\images\cc-nose-large-medium.png"
        if skin == 5 and lips == 1:
            "\images\cc-nose-large-olive.png"
        if skin == 6 and lips == 1:
            "\images\cc-nose-large-pale.png"
        if skin == 1 and lips == 2:
            "\images\cc-lips-small-brown.png"
        if skin == 2 and lips == 2:
            "\images\cc-lips-small-dark-brown.png"
        if skin == 3 and lips == 2:
            "\images\cc-nose-small-fair.png"
        if skin == 4 and lips == 2:
            "\images\cc-nose-small-medium.png"
        if skin == 5 and lips == 2:
            "\images\cc-nose-small-olive.png"
        if skin == 6 and lips == 2:
            "\images\cc-nose-small-pale.png"
        
        # Skin color
        if skin == 1:
            "\images\cc-skin-brown.png"
        if skin == 2:
            "\images\cc-skin-dark-brown.png"
        if skin == 3:
            "\images\cc-skin-fair.png"
        if skin == 4:
            "\images\cc-skin-medium.png"
        if skin == 5:
            "\images\cc-skin-olive.png"
        if skin == 6:
            "\images\cc-skin-pale.png"
   
    screen dollmaker():
        hbox:
            yalign 0.5
            xalign 0.5
            spacing 100

            vbox:
                text "haircolor"
                hbox:
                    textbutton "Prev" action Function(change_player, "haircolor", "-")
                    textbutton "Next" action Function(change_player, "haircolor", "+")

                text "hair"
                hbox:
                    textbutton "Prev" action Function(change_player, "hair", "-")
                    textbutton "Next" action Function(change_player, "hair", "+")
                
                text "eyeshape"
                hbox:
                    textbutton "Prev" action Function(change_player, "eyeshape", "-")
                    textbutton "Next" action Function(change_player, "eyeshape", "+")

                text "eyecolor"
                hbox:
                    textbutton "Prev" action Function(change_player, "eyecolor", "-")
                    textbutton "Next" action Function(change_player, "eyecolor", "+")

                text "nose"
                hbox:
                    textbutton "Prev" action Function(change_player, "nose", "-")
                    textbutton "Next" action Function(change_player, "nose", "+")

                text "lips"
                hbox:
                    textbutton "Prev" action Function(change_player, "lips", "-")
                    textbutton "Next" action Function(change_player, "lips", "+")

                text "skin"
                hbox:
                    textbutton "Prev" action Function(change_player, "skin", "-")
                    textbutton "Next" action Function(change_player, "skin", "+")

            add "player"

            textbutton "Done" action Return()

    init python:
        def change_player(aspect, way):
            global haircolor
            global hair
            global eyeshape
            global eyecolor
            global nose
            global lips
            global skin
            
            if aspect == "haircolor":
                if way == "+":
                    haircolor += 1
                if way == "-":
                    haircolor -= 1
            
            if haircolor > 6:
                haircolor = 1
            if haircolor < 1:
                haircolor = 6
            
            if aspect == "hair":
                if way == "+":
                    hair += 1
                if way == "-":
                    hair -= 1
            
            if hair > 1:
                hair = 1
            if hair < 1:
                hair = 1
            
            if aspect == "eyeshape":
                if way == "+":
                    eyeshape += 1
                if way == "-":
                    eyeshape -= 1
            
            if eyeshape > 2:
                eyeshape = 1
            if eyeshape < 1:
                eyeshape = 2
            
            if aspect == "eyecolor":
                if way == "+":
                    eyecolor += 1
                if way == "-":
                    eyecolor -= 1
            
            if eyecolor > 6:
                eyecolor = 1
            if eyecolor < 1:
                eyecolor = 6

            if aspect == "nose":
                if way == "+":
                    nose += 1
                if way == "-":
                    nose -= 1
            
            if nose > 2:
                nose = 1
            if nose < 1:
                nose = 2
            
            if aspect == "lips":
                if way == "+":
                    lips += 1
                if way == "-":
                    lips -= 1
            
            if lips > 2:
                lips = 1
            if lips < 1:
                lips = 2
        
            if aspect == "skin":
                if way == "+":
                    skin += 1
                if way == "-":
                    skin -= 1
            
            if skin > 6:
                skin = 1
            if skin < 1:
                skin = 6

User avatar
m_from_space
Miko-Class Veteran
Posts: 985
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Character Creator Crashing

#2 Post by m_from_space »

DewyNebula wrote: Mon Apr 22, 2024 2:40 am Hello. I recently got into RenPy and started working on a visual novel. I'm working on a character creator where you will choose colors to define other body parts. By that, I mean selecting a "blond" hair color and having the hair and eyelashes match. The option buttons for the eyes or hair limit them only to shape, not to cycle through all the different color options. Although I thought I had it figured out, my game crashed with no error report. I've posted my code below - any help would be appreciated. (Also, I'm aware there is only one hairstyle right now - currently making the asset for the other)
Does the game crash on load or when you do something in particular? It would help figuring out what's going on.

But here are some things I have to tell you:

1) label "start" is the entry point for when starting the game by clicking "Start" inside the main menu. It's not the entry point for your code and it doesn't make sense to put your init code, screens and images within the indentation of the start label. Your code structure should look something like this instead:

Code: Select all

# your variables
default hair = 1
default eyeshape = 1

init python:
    # ... your classes and functions here
    
# your images
layeredimage player:
    ...
    
# screens
screen dollmaker():
    ...
    
# the start label
label start:
    # the game starts here
2) When using an "if" clause, you want to use "elif" for mutually exclusive conditions, otherwise all if statements are checked even though they cannot be True anymore. So use "elif" for any other condition that is part of the same question.

Example:

Code: Select all

        # Hairstyle and color
        if hair == 1 and haircolor == 1:
            "\images\cc-hair-wavy-black.png"
        elif hair == 1 and haircolor == 2:
            "\images\cc-hair-wavy-blonde.png"
            
       # further optimization of the above
       if hair == 1:
           if haircolor == 1:
               "cc-hair-wavy-black"
           elif haircolor == 2:
               "cc-hair-wavy-blonde"
3) You do not have to write full or relative paths to images within Renpy. Renpy will recognize all images inside the "images" folder on startup and you can refer to them just using the filename, stripping the extension.

Example:

Code: Select all

"cc-hair-wavy-black"

# instead of

"/images/cc-hair-wavy-black.png"

DewyNebula
Newbie
Posts: 7
Joined: Sun Apr 21, 2024 10:57 am
Contact:

Re: Character Creator Crashing

#3 Post by DewyNebula »

Sorry, I didn't specify when the crash occurred; I'm new to posting here. Also, I did some fiddling, and now it doesn't crash getting to the character screen. My code was just out of order; it was my mistake. I still need to do some editing but its working!

Code: Select all

#Characters
define k = Character("Kelsey")

label character_creation:
    # Variables
    default skin = 1
    default mouth = 1
    default nose = 1
    default irises = 1
    default eyes = 1
    default haircolor = 1
    default hair = 1

    # Layered Images
    layeredimage player:
        # Skin color
        if skin == 1:
            "cc-skin-pale"                           
        if skin == 2:
            "cc-skin-fair"
        if skin == 3:
            "cc-skin-medium" 
        if skin == 4:
            "cc-skin-olive" 
        if skin == 5:
            "cc-skin-brown"  
        if skin == 6:
            "cc-skin-dark-brown" 

        # Mouth and color
        if mouth == 1 and skin == 1:
            "cc-mouth-small-pale"
        elif mouth == 1 and skin == 2:
            "cc-mouth-small-fair"
        elif mouth == 1 and skin == 3:
            "cc-mouth-small-medium"
        elif mouth == 1 and skin == 4:
            "cc-mouth-small-olive"
        elif mouth == 1 and skin == 5:
            "cc-mouth-small-brown"
        elif mouth == 1 and skin == 6:
            "cc-mouth-small-dark-brown" 
        if mouth == 2 and skin == 1:
            "cc-mouth-large-pale"
        elif mouth == 2 and skin == 2:
            "cc-mouth-large-fair"
        elif mouth == 2 and skin == 3:
            "cc-mouth-large-medium"
        elif mouth == 2 and skin == 4:
            "cc-mouth-large-olive"
        elif mouth == 2 and skin == 5:
            "cc-mouth-large-brown"
        elif mouth == 2 and skin == 6:
            "cc-mouth-large-dark-brown" 

        # Nose and color
        if nose == 1 and skin == 1:
            "cc-nose-small-pale"
        elif nose == 1 and skin == 2:
            "cc-nose-small-fair"
        elif nose == 1 and skin == 3:
            "cc-nose-small-medium"
        elif nose == 1 and skin == 4:
            "cc-nose-small-olive"
        elif nose == 1 and skin == 5:
            "cc-nose-small-brown"
        elif nose == 1 and skin == 6:
            "cc-nose-small-dark-brown" 
        if nose == 2 and skin == 1:
            "cc-nose-large-pale"
        elif nose == 2 and skin == 2:
            "cc-nose-large-fair"
        elif nose == 2 and skin == 3:
            "cc-nose-large-medium"
        elif nose == 2 and skin == 4:
            "cc-nose-large-olive"
        elif nose == 2 and skin == 5:
            "cc-nose-large-brown"
        elif nose == 2 and skin == 6:
            "cc-nose-large-dark-brown" 

        # Irises color
        if irises == 1:
            "cc-irises-blue"                           
        if irises == 2:
            "cc-irises-grey"
        if irises == 3:
            "cc-irises-green" 
        if irises == 4:
            "cc-irises-hazel" 
        if irises == 5:
            "cc-irises-amber"  
        if irises == 6:
            "cc-irises-ebony"

        # Eyes and color
        if eyes == 1 and haircolor == 1:
            "cc-eyes-small-blond"
        elif eyes == 1 and haircolor == 2:
            "cc-eyes-small-ginger"
        elif eyes == 1 and haircolor == 3:
            "cc-eyes-small-caramel"
        elif eyes == 1 and haircolor == 4:
            "cc-eyes-small-cinnamon"
        elif eyes == 1 and haircolor == 5:
            "cc-eyes-small-chocolate"
        elif eyes == 1 and haircolor == 6:
            "cc-eyes-small-black"
        if eyes == 2 and haircolor == 1:
            "cc-eyes-large-blond"
        elif eyes == 2 and haircolor == 2:
            "cc-eyes-large-ginger"
        elif eyes == 2 and haircolor == 3:
            "cc-eyes-large-caramel"
        elif eyes == 2 and haircolor == 4:
            "cc-eyes-large-cinnamon"
        elif eyes == 2 and haircolor == 5:
            "cc-eyes-large-chocolate"
        elif eyes == 2 and haircolor == 6:
            "cc-eyes-large-black"

        # Hair and color
        if hair == 1 and haircolor == 1:
            "cc-hair-wavy-blond"
        elif hair == 1 and haircolor == 2:
            "cc-hair-wavy-ginger"
        elif hair == 1 and haircolor == 3:
            "cc-hair-wavy-caramel"
        elif hair == 1 and haircolor == 4:
            "cc-hair-wavy-cinnamon"
        elif hair == 1 and haircolor == 5:
            "cc-hair-wavy-chocolate"
        elif hair == 1 and haircolor == 6:
            "cc-hair-wavy-black"                                                                                                               
    
    screen dollmaker():
        hbox:
            yalign 0.5
            xalign 0.5
            spacing 100

            vbox:
                text "hair"
                hbox:
                    textbutton "Prev" action Function(change_player, "hair", "-")
                    textbutton "Next" action Function(change_player, "hair", "+")

                text "haircolor"
                hbox:
                    textbutton "Prev" action Function(change_player, "haircolor", "-")
                    textbutton "Next" action Function(change_player, "haircolor", "+")
                
                text "eyes"
                hbox:
                    textbutton "Prev" action Function(change_player, "eyes", "-")
                    textbutton "Next" action Function(change_player, "eyes", "+")

                text "irises"
                hbox:
                    textbutton "Prev" action Function(change_player, "irises", "-")
                    textbutton "Next" action Function(change_player, "irises", "+")

                text "nose"
                hbox:
                    textbutton "Prev" action Function(change_player, "nose", "-")
                    textbutton "Next" action Function(change_player, "nose", "+")

                text "mouth"
                hbox:
                    textbutton "Prev" action Function(change_player, "mouth", "-")
                    textbutton "Next" action Function(change_player, "mouth", "+")

                text "skin"
                hbox:
                    textbutton "Prev" action Function(change_player, "skin", "-")
                    textbutton "Next" action Function(change_player, "skin", "+")

            add "player"

            textbutton "Done" action Return()

    init python:
        def change_player(aspect, way):
            global hair
            global haircolor
            global eyes
            global irises
            global nose
            global mouth
            global skin
            
            if aspect == "hair":
                if way == "+":
                    hair += 1
                if way == "-":
                    hair -= 1
            
            if hair > 1:
                hair = 1
            if hair < 1:
                hair = 1

            if aspect == "haircolor":
                if way == "+":
                    haircolor += 1
                if way == "-":
                    haircolor -= 1
            
            if haircolor > 6:
                haircolor = 1
            if haircolor < 1:
                haircolor = 6
            
            if aspect == "eyes":
                if way == "+":
                    eyes += 1
                if way == "-":
                    eyes -= 1
            
            if eyes > 2:
                eyes = 1
            if eyes < 1:
                eyes = 2
            
            if aspect == "irises":
                if way == "+":
                    irises += 1
                if way == "-":
                    irises -= 1
            
            if irises > 6:
                irises = 1
            if irises < 1:
                irises = 6

            if aspect == "nose":
                if way == "+":
                    nose += 1
                if way == "-":
                    nose -= 1
            
            if nose > 2:
                nose = 1
            if nose < 1:
                nose = 2
            
            if aspect == "mouth":
                if way == "+":
                    mouth += 1
                if way == "-":
                    mouth -= 1
            
            if mouth > 2:
                mouth = 1
            if mouth < 1:
                mouth = 2
        
            if aspect == "skin":
                if way == "+":
                    skin += 1
                if way == "-":
                    skin -= 1
            
            if skin > 6:
                skin = 1
            if skin < 1:
                skin = 6

# Game Start
label start:
    scene bg black
    with fade
    show npc-kelsey-neutral
    with dissolve

    k "welcome to the game!"

    scene bg creation
    with fade

    #Character Creation
    call screen dollmaker

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]