Multiple Character customization

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
lindsay-jb
Regular
Posts: 68
Joined: Tue Aug 25, 2020 1:05 am
Contact:

Multiple Character customization

#1 Post by lindsay-jb »

Hello! First of all, I'm not a very advanced programmer, I'm mostly just figuring it out by watching/reading tutorials. So, I'm working on character customization. I have my main MC customization screen working, but I wanted to add a separate screen to add customization depending on the gender you choose, as well as possibly to add customization for additional characters. However, if I do the same thing, just with different variable names, it says this:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00start.rpy", line 189, in script
    python:
  File "renpy/common/00start.rpy", line 189, in script
    python:
  File "renpy/common/00start.rpy", line 190, in <module>
    renpy.execute_default_statement(True)
Exception: store.race is being given a default a second time.
-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "C:\Users\Lindsay\Downloads\renpy-7.3.5-sdk\renpy\bootstrap.py", line 316, in bootstrap
    renpy.main.main()
  File "C:\Users\Lindsay\Downloads\renpy-7.3.5-sdk\renpy\main.py", line 578, in main
    run(restart)
  File "C:\Users\Lindsay\Downloads\renpy-7.3.5-sdk\renpy\main.py", line 143, in run
    renpy.execution.run_context(True)
  File "C:\Users\Lindsay\Downloads\renpy-7.3.5-sdk\renpy\execution.py", line 908, in run_context
    context.run()
  File "renpy/common/00start.rpy", line 189, in script
    python:
  File "renpy/common/00start.rpy", line 189, in script
    python:
  File "C:\Users\Lindsay\Downloads\renpy-7.3.5-sdk\renpy\ast.py", line 914, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\Lindsay\Downloads\renpy-7.3.5-sdk\renpy\python.py", line 2028, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/00start.rpy", line 190, in <module>
    renpy.execute_default_statement(True)
  File "C:\Users\Lindsay\Downloads\renpy-7.3.5-sdk\renpy\exports.py", line 3495, in execute_default_statement
    i.set_default(start)
  File "game/Dollmaker.rpyc", line 85, in set_default
Exception: store.race is being given a default a second time.
Here's what my character customization screens look like:

Code: Select all

init:
    default f_rowan_race = 1
    default f_rowan_race_max = 4
    default f_rowan_outfit = 1
    default f_rowan_outfit_max = 7
    default f_rowan_hair = 1
    default f_rowan_hair_max = 8

#####################################renpy langauge version:
image rowan = Composite(
    (0, 0),
        (0, 0), "Create_Character/Rowan_Female/Bodies/fmc[f_rowan_race].png",
        (0, 0), "Create_character/Rowan_Female/Outfits/fMC_Outfit[f_rowan_outfit].png",
        (0, 0), "Create_character/Rowan_Female/Hair/fMC_hair[f_rowan_hair].png",
)
#####################################python version:
init python:
    def f_rowan_sprite(st, at):
        return LiveComposite(
            (0, 0),
            (0, 0), "Create_Character/Rowan_Female/bodies/fmc{}.png".format(f_rowan_race),
            (0, 0), "Create_character/Rowan_Female/Outfits/fMC_Outfit{}.png".format(f_rowan_outfit),
            (0, 0), "Create_character/Rowan_Female/Hair/fMC_hair{}.png".format(f_rowan_hair),

        ),.1

screen f_race_rowan():
    modal True

    imagemap:
        ground "Dressup_Screen/background.png"
        idle "Dressup_Screen/idle.png"
        hover "Dressup_Screen/hover.png"
        selected_idle "Dressup_Screen/selected.png"
        selected_hover "Dressup_Screen/selected.png"


        ##F!Rowan Race##
        hotspot(47,959,75,130) action If(f_rowan_race > 1, SetVariable("f_rowan_race", f_rowan_race - 1), SetVariable("f_rowan_race", 1))
        hotspot(1068, 959, 70, 127) action If(f_rowan_race < f_rowan_race_max, SetVariable("f_rowan_race", f_rowan_race + 1), SetVariable("f_rowan_race", f_rowan_race_max))

        ##Continue##
        hotspot(137,1422,900,228) action Return()

        add "rowan":
            pos(0, 0)
screen f_hair_rowan():
    modal True

    imagemap:
        ground "Dressup_Screen/background.png"
        idle "Dressup_Screen/idle.png"
        hover "Dressup_Screen/hover.png"
        selected_idle "Dressup_Screen/selected.png"
        selected_hover "Dressup_Screen/selected.png"
        ##F!Rowan Hair##
        hotspot(47,959,75,130) action If(f_rowan_hair > 1, SetVariable("f_rowan_hair", f_rowan_hair - 1), SetVariable("f_rowan_hair", 1))
        hotspot(1068, 959, 70, 127) action If(f_rowan_hair < f_rowan_hair_max, SetVariable("f_rowan_hair", f_rowan_hair + 1), SetVariable("f_rowan_hair", f_rowan_hair_max))

        ##Continue##
        hotspot(137,1422,900,228) action Return()
        add "rowan":
            pos(0, 0)

screen outfit_rowan():
    modal True
    imagemap:
        ground "Dressup_Screen/background.png"
        idle "Dressup_Screen/idle.png"
        hover "Dressup_Screen/hover.png"
        selected_idle "Dressup_Screen/selected.png"
        selected_hover "Dressup_Screen/selected.png"
        ##F!Rowan Outfit##
        hotspot(47,959,75,130) action If(f_rowan_outfit > 1, SetVariable("f_rowan_outfit", f_rowan_outfit - 1), SetVariable("f_rowan_outfit", 1))
        hotspot(1068, 959, 70, 127) action If(f_rowan_outfit < f_rowan_outfit_max, SetVariable("f_rowan_outfit", f_rowan_outfit + 1), SetVariable("f_rowan_outfit", f_rowan_outfit_max))

        ##Continue##
        hotspot(137,1422,900,228) action Return()
        add "rowan":
            pos(0, 0)
Then the second screen looks like this:

Code: Select all

####Male Rowan###
init:
    default m_rowan_body = 1
    default m_rowan_body_max = 4
    default m_rowan_clothes = 1
    default m_rowan_clothes_max = 6
    default m_rowan_hairstyle = 1
    default m_rowan_hairstyle_max = 3

#####################################renpy langauge version:
image rowan = Composite(
    (0, 0),
        (0, 0), "Create_Character/Rowan_Male/Bodies/mmc[m_rowan_body].png",
        (0, 0), "Create_character/Rowan_Male/Outfits/mmc_Outfit[m_rowan_clothes].png",
        (0, 0), "Create_character/Rowan_Male/Hair/mmc_hair[m_rowan_hairstyle].png",
)
#####################################python version:
init python:
    def m_rowan_sprite(st, at):
        return LiveComposite(
            (0, 0),
            (0, 0), "Create_Character/Rowan_Male/bodies/mmc{}.png".format(m_rowan_body),
            (0, 0), "Create_character/Rowan_Male/Outfits/mMC_Outfit{}.png".format(m_rowan_clothes),
            (0, 0), "Create_character/Rowan_Male/Hair/mMC_hair{}.png".format(m_rowan_hairstyle),

        ),.1

screen m_body_rowan():
    modal True

    imagemap:
        ground "Dressup_Screen/background.png"
        idle "Dressup_Screen/idle.png"
        hover "Dressup_Screen/hover.png"
        selected_idle "Dressup_Screen/selected.png"
        selected_hover "Dressup_Screen/selected.png"


        ##M!Rowan body##
        hotspot(47,959,75,130) action If(m_rowan_body > 1, SetVariable("m_rowan_body", m_rowan_body - 1), SetVariable("m_rowan_body", 1))
        hotspot(1068, 959, 70, 127) action If(m_rowan_body < m_rowan_body_max, SetVariable("m_rowan_body", m_rowan_body + 1), SetVariable("m_rowan_body", m_rowan_body_max))

        ##Continue##
        hotspot(137,1422,900,228) action Return()

        add "rowan":
            pos(0, 0)
screen m_hairstyle_rowan():
    modal True

    imagemap:
        ground "Dressup_Screen/background.png"
        idle "Dressup_Screen/idle.png"
        hover "Dressup_Screen/hover.png"
        selected_idle "Dressup_Screen/selected.png"
        selected_hover "Dressup_Screen/selected.png"
        ##M!Rowan Hair##
        hotspot(47,959,75,130) action If(m_rowan_hairstyle > 1, SetVariable("m_rowan_hairstyle", m_rowan_hairstyle - 1), SetVariable("m_rowan_hairstyle", 1))
        hotspot(1068, 959, 70, 127) action If(m_rowan_hairstyle < m_rowan_hairstyle_max, SetVariable("m_rowan_hairstyle", m_rowan_hairstyle + 1), SetVariable("m_rowan_hairstyle", m_rowan_hairstyle_max))

        ##Continue##
        hotspot(137,1422,900,228) action Return()
        add "rowan":
            pos(0, 0)

screen m_clothes_rowan():
    modal True
    imagemap:
        ground "Dressup_Screen/background.png"
        idle "Dressup_Screen/idle.png"
        hover "Dressup_Screen/hover.png"
        selected_idle "Dressup_Screen/selected.png"
        selected_hover "Dressup_Screen/selected.png"
        ##M!Rowan Outfit##
        hotspot(47,959,75,130) action If(m_rowan_clothes > 1, SetVariable("m_rowan_clothes", m_rowan_clothes - 1), SetVariable("m_rowan_clothes", 1))
        hotspot(1068, 959, 70, 127) action If(m_rowan_clothes < m_rowan_clothes_max, SetVariable("m_rowan_clothes", m_rowan_clothes + 1), SetVariable("m_rowan_clothes", m_rowan_clothes_max))

        ##Continue##
        hotspot(137,1422,900,228) action Return()
        add "rowan":
            pos(0, 0)
Is there a way to make multiple customization screens for separate characters? Thanks in advance!

cheonbyeol
Regular
Posts: 37
Joined: Thu Feb 04, 2021 9:04 am
Contact:

Re: Multiple Character customization

#2 Post by cheonbyeol »

Just a side note, this post would fit better in "Renpy questions and announcements".

But I'm looking at your code, and baffled by the error you get. I don't even see a variable named "race" on its own. But the error seems to be coming from an .rpyc file. I don't have much experience with this, but if you've changed the .rpy since, I'd try deleting the .rpyc, or building the game again, it might be a conflict between different versions of the same code.

lindsay-jb
Regular
Posts: 68
Joined: Tue Aug 25, 2020 1:05 am
Contact:

Re: Multiple Character customization

#3 Post by lindsay-jb »

Hahah yeah, I realized that after I posted this 😅 thanks for the response though! I deleted that file and it started working. I was also confused by the error when it wasn’t even a variable. Thanks for the help!

Post Reply

Who is online

Users browsing this forum: Andredron