[Solved] Ren'py imgmap help: Grey-out places you've visited

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
AvalonMelody
Regular
Posts: 44
Joined: Thu May 29, 2014 2:14 am
Contact:

[Solved] Ren'py imgmap help: Grey-out places you've visited

#1 Post by AvalonMelody »

Hello! I'm looking for some assistance using the imgmap in Ren'Py. I've already set it up and it works fine when clicking the locations, so no worries on that part. (I apologize that this is a very long topic post! I'm hoping if I explain the situation in detail it might make the question clearer. I have placed a summary of it at the bottom of the post if it's too long/confusing!)

Also, I am using Ren'Py version 6.17 and use Editra to edit the script, if that's important information!

In the visual novel I am making, the player get's to see a map and chose where to go. There are five locations all together, two which lead to an ending (thus I won't mention those; we don't see the imgmap re-appear!) two which proceed the storyline [cafe, library] (as long as you have visited both!) and one that is completely optional [park]. (regardless of if you have visited this place, the story will progress so long as you visited the other two places)

Upon entering these places and viewing the scene that occurs at the location, the map will reappear for the player to chose another location. But when the map reappears, I want to make the location they were just at greyed out/do nothing when clicked. (Since they've already been there!)

This wouldn't be too hard I think, since with my current beginner knowledge with Ren'Py, I would use a mix of labels and imgmaps. *just redraw the 'select' images; leave 'ground' as is and create new imgmaps for the end of each location*

But, if you take into account the [park] and how it can be visited at any time (before visiting the [cafe] and/or [library] and in between the [cafe] and [library]) I need to make it so that the park will be greyed out if it's been visited. (In a sense, taking into account any order that the player visits and making necessary changes to the map)

To do this, I figured something like a [park] flag would possibly be involved and when pulling up the map at the end of the [library] scene and/or [cafe] scene, it must check if the [park] flag is true, but that's all I've got. I don't really know how to go about that (or if there's an easier way!)

Does anyone have a solution or ideas on how to get this done (not exactly the way I described of course, any way that can work is accepted!)

I have a feeling it's going to involve a lot of 'select' screen images. (>A< )...

Thanks in advance for any assistance!
(And I hope this explaination makes sense! I'll do my best to restate it in a different way if it's too confusing, so please let me know if it is.)

EDIT: As an extra note, the current 'select' images I have are:
only [park] greyed out
only [library] greyed out
only [cafe] greyed out
[cafe] and [park] greyed out
[library] and [park] greyed out
Maybe these can help with the solution to the problem? I'm sure they'll have to be used at least. :?:
Last edited by AvalonMelody on Sat May 20, 2017 6:37 pm, edited 1 time in total.

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Ren'py imgmap help: Grey-out places you've visited

#2 Post by Asceai »

First of all, refresh your knowledge of flags. You are correct- you need them here.

Code: Select all

label start:
    $park = False
    $library = False
    $cafe = False
Now, while you can do things the way you described (with those 5 images with all the different greyed out combinations) there is a way that is both easier and less image-intensive.
Imagemaps have an optional 'insensitive' image - these are for buttons that cannot be clicked. This is exactly what you want.

So, what you want is:
- a normal 'ground' image
- an 'insensitive' image, with all the locations greyed out
- an 'idle' image, with all the locations in colour
- (optionally) a 'hover' image with the locations in colour and possibly highlighted or glowing or something, just to indicate that you've selected them.

To make the hotspots insensitive if a certain condition is met or not met, you want the If action - you can leave either the true or false argument as None to render it insensitive, as the documentation describes:
Note that the default, None, can be used as an action that causes a button to be disabled.
The other argument you then set as the action you want to happen when the button is clicked and it isn't disabled.

Now, create your imagemap as follows:

Code: Select all

screen map:
    modal True
    imagemap:
        ground "map_ground.png"
        insensitive "map_grey.png"
        idle "map_colour.png"

        hotspot (100, 100, 64, 64) clicked If(park, false=Jump("park"))
        hotspot (200, 200, 64, 64) clicked If(library, false=Jump("library"))
        hotspot (300, 300, 64, 64) clicked If(cafe, false=Jump("cafe"))
You can then just use the imagemap and labels as normal, remembering to set a flag after you've been to each location, then checking them all each time to determine when you're done.

Code: Select all

label map_loop:
    if park and library and cafe:
        jump map_done
    "Hmm, what shall I do now?"
    call screen map
label park:
    $park = True
    "I sat around the park for about fifteen minutes. It was uneventful but peaceful."
    jump map_loop
label library:
    $library = True
    "Idly, I leafed through novels at the library for half an hour before getting bored and leaving."
    jump map_loop
label cafe:
    $cafe = True
    "I sat down at an empty table in the cafe. A few minutes later, the barista asked me if I wanted coffee and I had to leave."
    jump map_loop
label map_done:
    "There was nothing else to do. I decided to just go home."
    return

User avatar
AvalonMelody
Regular
Posts: 44
Joined: Thu May 29, 2014 2:14 am
Contact:

Re: Ren'py imgmap help: Grey-out places you've visited

#3 Post by AvalonMelody »

Thanks for your quick reply! I've typed it out in the script and I think it's almost working, but I get this error and I'm not sure how to remedy it. ( >.< )

File "game/script.rpy", line 691: u'if' is not a keyword argument or valid child for the label statement.
if library and cafe:

This is a few of the lines from the script:

Code: Select all

label map_loop:
    if library and cafe:
        jump map_done
    call screen map

User avatar
wyverngem
Miko-Class Veteran
Posts: 615
Joined: Mon Oct 03, 2011 7:27 pm
Completed: Simple as Snow, Lady Luck's Due,
Projects: Aether Skies, Of the Waterfall
Tumblr: casting-dreams
itch: castingdreams
Location: USA
Contact:

Re: Ren'py imgmap help: Grey-out places you've visited

#4 Post by wyverngem »

Did you try writing them out the long way?

Code: Select all

init:
    $ seen_cafe = False
    $ seen_library = False

label start:
    if seen_cafe == True and seen_library == True:
        jump CafeScene

Aside: "seen_cafe" is the same as your "cafe" variable. It's just a habit to use descriptive variables you can remember.

User avatar
AvalonMelody
Regular
Posts: 44
Joined: Thu May 29, 2014 2:14 am
Contact:

Re: Ren'py imgmap help: Grey-out places you've visited

#5 Post by AvalonMelody »

Thank you for that! I think it worked (and I've relabelled the flags too!), but now I have a new error. >.<

Code: Select all

File "game/script.rpy", line 696: u'a' is not a keyword argument or valid child for the label statement.
    a "Well, there's a bar not too far from here. Maybe France or England will be hanging out there."
Here's the lines it comes from though: (As well as the imagemap!)

Code: Select all

            screen map:
                modal True
                imagemap:
                    ground "tourist map ground.png"
                    insensitive "tourist map insenstive.png"
                    idle "tourist map select.png"
                    hover "tourist map hover.png"

                    hotspot (124, 368, 366, 523) clicked If(park_flag, false=Jump("park"))
                    hotspot (526, 225, 756, 357) clicked If(library_flag, false=Jump("library"))
                    hotspot (484, 412, 707, 544) clicked If(cafe_flag, false=Jump("cafe"))
                    hotspot (51, 142, 301, 303) Play ("mall")
                    hotspot (304, 19, 499, 144) Play ("pub")

                    label pub:
                        a "Hannah, are you here?"

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Ren'py imgmap help: Grey-out places you've visited

#6 Post by Asceai »

Watch your indenting! Top-level statements should always be against the left side of the screen. I don't care if they sometimes work when indented- it will prevent a lot of headaches. Top-level statements are anything that doesn't go in another block, so:

init: (and init python: and other related statements)
image
define
screen [whatever]:
label [whatever]:
style

These are top-level statements so put them against the left side. You can make an exception for things like image and define if you want to put them near where you actually use them, providing you remember that they are top-level statements. This is really important.

Code: Select all

screen map:
    modal True
    imagemap:
        ground "tourist map ground.png"
        insensitive "tourist map insenstive.png"
        idle "tourist map select.png"
        hover "tourist map hover.png"

        hotspot (124, 368, 366, 523) clicked If(park_flag, false=Jump("park"))
        hotspot (526, 225, 756, 357) clicked If(library_flag, false=Jump("library"))
        hotspot (484, 412, 707, 544) clicked If(cafe_flag, false=Jump("cafe"))
        hotspot (51, 142, 301, 303) Play ("mall")
        hotspot (304, 19, 499, 144) Play ("pub")

label pub:
    a "Hannah, are you here?"
EDIT: Also, what are those 'Play' things for?

User avatar
AvalonMelody
Regular
Posts: 44
Joined: Thu May 29, 2014 2:14 am
Contact:

Re: Ren'py imgmap help: Grey-out places you've visited

#7 Post by AvalonMelody »

Ah, got it! Thank you for the fast reply! I looked back in the script and fixed a few indentation lines so things line up better!
Sorry! Please ignore what was posted here if you saw it! I've fixed them myself, I forgot the 'clicked' by the Play and adding what happens when the flags are True! I'll see if there's anything else wrong and re-edit the post if I find something in the next ten minutes. XD
Last edited by AvalonMelody on Thu May 29, 2014 7:45 pm, edited 1 time in total.

Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: Ren'py imgmap help: Grey-out places you've visited

#8 Post by Asceai »

Code: Select all

File "game/script.rpy", line 688: u'Play' is not a keyword argument or valid child for the hotspot statement.
    hotspot (51, 142, 301, 303) Play ("mall")
Well, that's giving an error because you forgot 'clicked'. What's this supposed to do anyway?

Code: Select all

File "game/script.rpy", line 976: if statement expects a non-empty block.
    if cafe_flag == True and library_flag == True:
Don't unindent stuff that's supposed to be in blocks. Code I wrote is all indented correctly. Use it as a guide.

User avatar
AvalonMelody
Regular
Posts: 44
Joined: Thu May 29, 2014 2:14 am
Contact:

Re: Ren'py imgmap help: Grey-out places you've visited

#9 Post by AvalonMelody »

Yes, sorry I just noticed and fixed it a few minutes after you posted that! I apologize for wasting your time for that!

I believe I've got it; the map shows up and park greys out after visiting! (So do the other locations!) *Though looks like I'll have to fix the coordinates again. Looks like I'll need to make square shaped buttons instead of circles!*

Thank you so much for your patience with my fails! I really appreciate it!

Shaylayy
Newbie
Posts: 5
Joined: Mon Jan 19, 2015 6:39 pm
Deviantart: IceWolfNight98
Contact:

Re: Ren'py imgmap help: Grey-out places you've visited

#10 Post by Shaylayy »

This is a great code, and it worked fantastically for me!
But one thing keeps happening.
Whenever I've already selected something and it returns to the choice again, the thing I already selected is changed to view the image of another spot, as well as the hover version D:

This is the original scene with nothing highlighted. The idle version, I guess:
Capture2.JPG

Then this is what it looks like when you highlight the hammock, which is an explorable area:
Capture3.JPG
Capture3.JPG (19.05 KiB) Viewed 2721 times
But after you click it and go through the cutscene that follows it, when you return to this scene to search another place this comes up:
Capture4.JPG

This is my code:

Code: Select all

    c "The others are looking at different parts of the grove. I should see what I can find here."
    
    $uptree = False
    $intree = False
    $hammock = False
    $elsewhere = False
    
screen lgrove_imagemap:
    
    modal True
    
    imagemap:
        
        ground "lgrove_objectgame/lgrove_ground.png"
        hover "lgrove_objectgame/lgrove_hover.png"
        insensitive "lgrove_objectgame/lgrove_insensitive.png"
            
        hotspot (343, 255, 60, 103) clicked If(intree, false=Jump("intree")) 
        hotspot (416, 260, 108, 106) clicked If(hammock, false=Jump("hammock")) 
        hotspot (631, 161, 96, 201) clicked If(elsewhere, false=Jump("elsewhere")) 
        hotspot (301, 111, 75, 55) clicked If(uptree, false=Jump("uptree"))
I'm probably missing something simple :P
Thanks!
Last edited by Shaylayy on Sun Jan 25, 2015 8:31 pm, edited 1 time in total.

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Ren'py imgmap help: Grey-out places you've visited

#11 Post by philat »

Just fyi, your image links aren't working. Not sure what you mean just by your description.

Shaylayy
Newbie
Posts: 5
Joined: Mon Jan 19, 2015 6:39 pm
Deviantart: IceWolfNight98
Contact:

Re: Ren'py imgmap help: Grey-out places you've visited

#12 Post by Shaylayy »

I edited it. I tried deleting some of the cache, and it worked for a bit, but then the problem returns when the image i deleted is stored in the cache again.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Lacha, Sirifys-Al