Wardrobe problems

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
khezo
Newbie
Posts: 3
Joined: Sun Oct 30, 2022 7:00 am
Contact:

Wardrobe problems

#1 Post by khezo » Sun Oct 30, 2022 7:47 am

Hi! Need some help!
I'm working on a wardrobe. I'm basing it on viewtopic.php?f=52&t=56853&p=518898&hil ... up#p518898
I will be adding new characters later. So in the places where variables change, I have added chara+

Code: Select all

### This is roughly what commposit looks like

init:
    default sakura_handB = 1
    default sakura_body = 1
    
  image sakura = Composite(
    (810, 1440),
    (0, 0), "chara/sakura/body/handB/sakura_handb[sakura_handB].png",
    (0, 0), "chara/sakura/body/base/sakura_body[sakura_body].png",
 )
  


Code: Select all


screen wardrobe(chara):
	imagemap:
       		idle "gui/wardrobe/wardrobe2.png"
        	hover "gui/wardrobe/wardrobe3.png"
        	selected_idle "gui/wardrobe/wardrobe1.png"
        	selected_hover "gui/wardrobe/wardrobe1.png"
       
        	hotspot(500, 200, 280, 150) action SetVariable(chara+"_eyes", 1) ### There's a hotspot for changing eyes
        
      
I want to implement two arrows. As in the example. Clicking on which flips through all the eye, hair, etc. options in order.

Code: Select all

	###That's how it worked out for me. The downside is that in order to add another character, I need to add two lines to each category
       		#<eye#
        	hotspot(1580, 210, 175, 120):
            		if chara == "hermione":
                 		action If(hermione_eyes > 1, SetVariable("hermione_eyes", hermione_eyes - 1), SetVariable("hermione_eyes", 1))
            		elif chara == "sakura":
                		action If(sakura_eyes > 1, SetVariable("sakura_eyes", sakura_eyes - 1), SetVariable("sakura_eyes", 1))

        	#eye>#
        	hotspot(1755, 210, 175, 120):
            		if chara == "hermione":
                		action If(hermione_eyes < hermione_eyes_max, SetVariable("hermione_eyes", hermione_eyes + 1), SetVariable("hermione_eyes", hermione_eyes_max))
            		elif chara == "sakura":
                		action If(sakura_eyes < sakura_eyes_max, SetVariable("sakura_eyes", sakura_eyes + 1), SetVariable("sakura_eyes", sakura_eyes_max))

That's about what I would like it to look like. But it's not working out for me.

Code: Select all


        hotspot(1580, 210, 175, 120) action If(chara+"_eyes" > 1, SetVariable(chara+"_eyes", chara+"_eyes" - 1), SetVariable(chara+"_eyes", 1))
        hotspot(1755, 210, 175, 120) action If(chara+"_eyes" < chara+"_eyes_max", SetVariable(chara+"_eyes", chara+"_eyes" + 1), SetVariable(chara+"_eyes", chara+"_eyes_max"))

I hope I have managed to explain my problem :)
I just started to learn RenPy
I will be very glad if somebody could help me.

User avatar
_ticlock_
Veteran
Posts: 391
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Wardrobe problems

#2 Post by _ticlock_ » Sun Oct 30, 2022 12:28 pm

khezo wrote:
Sun Oct 30, 2022 7:47 am

Code: Select all


        hotspot(1580, 210, 175, 120) action If(chara+"_eyes" > 1, SetVariable(chara+"_eyes", chara+"_eyes" - 1), SetVariable(chara+"_eyes", 1))
        hotspot(1755, 210, 175, 120) action If(chara+"_eyes" < chara+"_eyes_max", SetVariable(chara+"_eyes", chara+"_eyes" + 1), SetVariable(chara+"_eyes", chara+"_eyes_max"))

In the condition inside the IF action you compare sting and number:
"hermione_eyes" > 1 or "sakura_eyes" > 1
Instead, you should compare the value of the variables.
hermione_eyes > 1 or sakura_eyes > 1

One way to do it: getattr(store, chara+"_eyes"). Same goes for the value of the variable in SetVariable:

Code: Select all

        hotspot(1580, 210, 175, 120) action If(getattr(store, chara+"_eyes") > 1, SetVariable(chara+"_eyes", getattr(store, chara+"_eyes") - 1), SetVariable(chara+"_eyes", 1))
        hotspot(1755, 210, 175, 120) action If(getattr(store, chara+"_eyes") < getattr(store, chara+"_eyes_max"), SetVariable(chara+"_eyes", getattr(store, chara+"_eyes") + 1), SetVariable(chara+"_eyes", getattr(store, chara+"_eyes_max")))

User avatar
khezo
Newbie
Posts: 3
Joined: Sun Oct 30, 2022 7:00 am
Contact:

Re: Wardrobe problems

#3 Post by khezo » Sun Oct 30, 2022 1:22 pm

Everything works!
Thank you so much!

Post Reply

Who is online

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