how to "redeclare" images?

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
milksoda
Newbie
Posts: 21
Joined: Mon Sep 05, 2016 5:29 pm
Contact:

how to "redeclare" images?

#1 Post by milksoda »

im currently coding a game where i want the the player to be able to change the character's outfit, so it'll show up in cutscenes. how it works it that the sprite is replaced by different images according to which value 'outfit' is set to, so it's the same animations, just wearing different clothes.
i used 'conditionswitch' for this,

Code: Select all

image sato = ConditionSwitch(
    "outfit=='h'", "images/h_sato.png",
    "outfit=='f'", "images/f_sato.png")
and put the default "outfit" value before the start label:

Code: Select all

init:
    $ outfit = "h"
in order to change clothes the player can visit the closet screen, (which is a hacked up version of the tutorials screen, if it helps), and the outfit value is set after picking a choice.
example of one of the possible choices vvvv

Code: Select all

label csf:
$ outfit == "f"
scene closet with Dissolve(0.5)
show cf
"very classy!"
and it works, except for the fact that once the game has done the initial image declaring upon startup it doesn't revisit the code whenever the outfit value is changed, so the new outfit doesn't show up, and the character will still wear the default one that's been previously declared.

is there any way to make the game "redeclare" images? it's kind of a bummer to not be able to change clothes...

jw2pfd
Regular
Posts: 87
Joined: Tue Sep 18, 2012 9:55 pm
Location: DFW, TX, USA
Contact:

Re: how to "redeclare" images?

#2 Post by jw2pfd »

Try this:

Code: Select all

label csf:
   $ outfit = "f"  #<-- this is the only line to change, make it a single equals sign
   scene closet with Dissolve(0.5)
   show cf
   "very classy!"
There is a difference between the single equals and double equals. A single equals will assign a value. The double equals evaluates whether the statement is True or False.

milksoda
Newbie
Posts: 21
Joined: Mon Sep 05, 2016 5:29 pm
Contact:

Re: how to "redeclare" images?

#3 Post by milksoda »

thank you! it worked!

Post Reply

Who is online

Users browsing this forum: Google [Bot]