Using IF inside IMAGEMAP and SCREEN

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
Lezalith
Regular
Posts: 82
Joined: Mon Dec 21, 2015 6:45 pm
Contact:

Using IF inside IMAGEMAP and SCREEN

#1 Post by Lezalith » Tue Dec 22, 2015 2:30 pm

Code: Select all

screen study:
    tag mains
    if TeachingChosen == 1:
        add "teachingButton.png" at x2
    else:
        pass
    imagemap:
        ground "Teaching.png"
        hotspot (110, 110, 100, 100) hovered Show("Desc1") unhovered Hide("Desc1") action [(SetVariable("InTeaching", "Skill1")),(SetVariable("TeachingChosen", "1"))]
        hotspot (110, 280, 100, 100) hovered Show("Desc2") unhovered Hide("Desc2") action [(SetVariable("InTeaching", "Skill2")),(SetVariable("TeachingChosen", "1"))]
        hotspot (110, 460, 100, 100) hovered Show("Desc3") unhovered Hide("Desc3") action [(SetVariable("InTeaching", "Skill3")),(SetVariable("TeachingChosen", "1"))]
        if TeachingChosen == 1:
            hotspot (1050, 100, 100, 100) action Show("teaching_done", transition=fade),Hide("study")
        else:
            pass
        hotspot (1050, 670, 100, 100) action Show("main_screen", transition=dissolve),Hide("study")
One of the three hotspots will set two variables, one of them is supposed to enable another hotspot and add an image.
I checked the variables in developer menu and they are changed by the hotspots, but the image and hotspot are still not showing.
I tried changing the "if" controlling ADD to "showif", which did nothing.
And I'm pretty sure I cannot use "if" inside of imagemaps, but I dunno how else to do it.

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: Using IF inside IMAGEMAP and SCREEN

#2 Post by mobychan » Tue Dec 22, 2015 2:51 pm

Your image is hidden under your ground image and showif should work when using screen variables
I didn't test it, but it should technically work

Code: Select all

screen study:
    default screen_teching_chosen = 0
    tag mains
    imagemap:
        ground "Teaching.png"
        hotspot (110, 110, 100, 100) hovered Show("Desc1") unhovered Hide("Desc1") action [(SetVariable("InTeaching", "Skill1")),(SetVariable("TeachingChosen", "1")), SetScreenVariable("screen_teching_chosen", 1)]
        hotspot (110, 280, 100, 100) hovered Show("Desc2") unhovered Hide("Desc2") action [(SetVariable("InTeaching", "Skill2")),(SetVariable("TeachingChosen", "1")), SetScreenVariable("screen_teching_chosen", 1)]
        hotspot (110, 460, 100, 100) hovered Show("Desc3") unhovered Hide("Desc3") action [(SetVariable("InTeaching", "Skill3")),(SetVariable("TeachingChosen", "1")), SetScreenVariable("screen_teching_chosen", 1)]

        showif screen_teching_chosen == 1:
            add "teachingButton.png" at x2
            hotspot (1050, 100, 100, 100) action Show("teaching_done", transition=fade),Hide("study")
        hotspot (1050, 670, 100, 100) action Show("main_screen", transition=dissolve),Hide("study")

User avatar
Lezalith
Regular
Posts: 82
Joined: Mon Dec 21, 2015 6:45 pm
Contact:

Re: Using IF inside IMAGEMAP and SCREEN

#3 Post by Lezalith » Tue Dec 22, 2015 3:41 pm

Yea, that works, but how come the picture is ABOVE the ground when used like this, but normally it is UNDER?

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: Using IF inside IMAGEMAP and SCREEN

#4 Post by mobychan » Tue Dec 22, 2015 6:00 pm

if you want something to be UNDER something else, put the code AFTER it.
Just think of it like putting one piece of paper above another

Post Reply

Who is online

Users browsing this forum: Google [Bot], _ticlock_