problems with defining an image

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
ChrisWilson

problems with defining an image

#1 Post by ChrisWilson »

i'm making a game that will have the player change according to their answer like

image d = "d.jpg"
image b = "b.jpg"
$de = 0
$br = 0
menu:
e "question"
"answer 1":
$de+=1
"answer 2":
$br+=1
if de > br:
$p = Character('playerd')
image player = "d.jpg"
else:
image player = "b.jpg"
$p = Character('playerb')

p "why does it not work"
show player at left


the p always works but no matter what answer they chose it will always show player as being the else's image... why and how do i fix this?

JQuartz
Eileen-Class Veteran
Posts: 1265
Joined: Fri Aug 31, 2007 7:02 am
Projects: 0 completed game. Still haven't made any meaningfully completed games...
Contact:

Re: problems with defining an image

#2 Post by JQuartz »

ChrisWilson wrote:how do i fix this?
Use ConditionSwitch like so:

Code: Select all

init:
    image player = ConditionSwitch(
        "chosen_image == 'd'", "d.jpg",
        "chosen_image == 'b'", "b.jpg",
        )
label start:
    $de = 0
    $br = 0
    menu:
        "question"
        "answer 1":
            $de+=1
        "answer 2":
            $br+=1
    if de > br:
        $ p = Character('playerd')
        $ chosen_image='d'
    else:
        $ p = Character('playerb')
        $ chosen_image='b'
    show player at left
    p "why does it work"
I suspect somebody is stealing my internet identity so don't believe everything I tell you via messages. I don't post or send messages anymore so don't believe anything I tell you via messages or posts.

Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot]