imagemap, True and if statment not obeying properly [solved]

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
M.T.D.G.
Regular
Posts: 112
Joined: Sun Jun 01, 2008 12:37 pm
Completed: -SacrifiXi (BxB)-Beta-Love (BxB)-Ivan Berk Dress Up Game-Kiss the Cock (BxG)
Projects: -Death on Holiday (BxG)
Tumblr: mtdg
Deviantart: M-T-D-G
itch: mtdg
Location: Italy
Contact:

imagemap, True and if statment not obeying properly [solved]

#1 Post by M.T.D.G. »

Hi, dear colleagues!
I'd like the players to be able to choose a skin color at the beginning of the game through an imagemap, thus showing a different CG depending on what they picked.
The problem is that, no matter what I pick, I always end up with the last skin color I coded (which is black).
Here's my code:

The imagemap before the start label:

Code: Select all

screen skin:
    imagemap:
        ground "skin 1.png"
        hover "skin 2.png"
        
        hotspot (28, 136, 293, 259) action Return (white)
        hotspot (372, 136, 293, 259) action Return (caramel)
        hotspot (708, 136, 293, 259) action Return (black)
After the start label:

Code: Select all

label start:
    $ white = False
    $ caramel = False
    $ black = False
    
    $ renpy.transition(dissolve)
    call screen skin
    $ result = _return
    
    if result == "white": 
        $ white = True
    elif result == "caramel":
        $ caramel = True
    else:
        $ black = True

The moment the proper illustration should appear instead of giving me the black option everytime:

Code: Select all

if white == True:
        show cg1
        with dissolve
        character "..."
    
    elif caramel == True:
        show cg2
        with dissolve
        character "..."
    
    else:
        show cg3
        with dissolve
        character "..."
I hope somebody can help me. I'm no coder and I'm totally lost when issues like this happen
Last edited by M.T.D.G. on Mon Jan 18, 2016 4:33 am, edited 1 time in total.
mtdg.tumblr.com (nsfw)

ImageImageImageImageImage

User avatar
mobychan
Veteran
Posts: 275
Joined: Fri Apr 24, 2015 6:31 am
Projects: The Chosen - Sakura Pink & Gentian Blue
Organization: Foresoft
Location: Germany
Contact:

Re: imagemap, True and if statment not obeying properly

#2 Post by mobychan »

You're asking it for strings but return the values in your variables:

Code: Select all

        hotspot (28, 136, 293, 259) action Return ("white")
        hotspot (372, 136, 293, 259) action Return ("caramel")
        hotspot (708, 136, 293, 259) action Return ("black")

User avatar
M.T.D.G.
Regular
Posts: 112
Joined: Sun Jun 01, 2008 12:37 pm
Completed: -SacrifiXi (BxB)-Beta-Love (BxB)-Ivan Berk Dress Up Game-Kiss the Cock (BxG)
Projects: -Death on Holiday (BxG)
Tumblr: mtdg
Deviantart: M-T-D-G
itch: mtdg
Location: Italy
Contact:

Re: imagemap, True and if statment not obeying properly

#3 Post by M.T.D.G. »

mobychan wrote:You're asking it for strings but return the values in your variables:

Code: Select all

        hotspot (28, 136, 293, 259) action Return ("white")
        hotspot (372, 136, 293, 259) action Return ("caramel")
        hotspot (708, 136, 293, 259) action Return ("black")
That worked wonderfully!!! My huge thanks!!!!!!
mtdg.tumblr.com (nsfw)

ImageImageImageImageImage

Post Reply

Who is online

Users browsing this forum: peach_light