Imagemap Expected Statement Problem [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
bleating
Newbie
Posts: 4
Joined: Tue Jan 22, 2013 5:13 am
Contact:

Imagemap Expected Statement Problem [Solved]

#1 Post by bleating »

Here's the current error I'm getting:

Code: Select all

File "game/screens.rpy", line 5: expected statement.
            hotspot (190, 240, 470, 280) clicked Return("store_m")
                    ^
And here's the full segment of code:

Code: Select all

screen i_map:
    imagemap:
        auto "imagemap_%s.jpg"
        
        hotspot (190, 240, 470, 280) clicked Return("store_m")
        hotspot (410, 460, 560, 510) clicked Return("square_m")
        hotspot (220, 570, 470, 620) clicked Return("inn_m")
        hotspot (670, 570, 890, 620) clicked Return("castle_m")
I'm super new to this and I've managed to wrestle a bunch of problem solo until now by searching the wiki and the forums carefully, but I feel super stupid because in spite of that, no matter what I do, I just can't get this image map to work out. Even copying and pasting other peoples' code isn't working, so I'm sure I'm making some very silly error. Hopefully someone can provide me with an "Oh, duh" moment? :?
Last edited by bleating on Thu Jan 24, 2013 9:25 am, edited 1 time in total.

User avatar
astrobread
Newbie
Posts: 13
Joined: Mon Jan 21, 2013 4:01 am
Contact:

Re: Imagemap Expected Statement Problem

#2 Post by astrobread »

Does it work if you change it to:

hotspot (190, 240, 470, 280) action Return("store_m")

I think clicked is used for ImageButtons, not for ImageMaps.

User avatar
bleating
Newbie
Posts: 4
Joined: Tue Jan 22, 2013 5:13 am
Contact:

Re: Imagemap Expected Statement Problem

#3 Post by bleating »

I had tried action as well since I've seen both used in code examples but they both return the exact same error.

User avatar
astrobread
Newbie
Posts: 13
Joined: Mon Jan 21, 2013 4:01 am
Contact:

Re: Imagemap Expected Statement Problem

#4 Post by astrobread »

Looks like it works fine on mine too.. After reading a few of these posts, the only way I was able to reproduce the error was by messing up the indentation like this:

Code: Select all

screen i_map:           
    imagemap:
        auto "old_paper-%s.jpg"
                
hotspot (190, 240, 470, 280) clicked Return("store_m")    
If you could post some additional code that might help me spot what's going on.

User avatar
bleating
Newbie
Posts: 4
Joined: Tue Jan 22, 2013 5:13 am
Contact:

Re: Imagemap Expected Statement Problem [Updated issue]

#5 Post by bleating »

I mean, that's the whole chunk. Could it be an issue with positioning or where I've put it? I tried putting it in the scenes script, I tried putting it in the game's main script as well, near the beginning where everything else is defined but with the appropriate spacing and indentations, and in both cases it returned the same error. Everything works perfectly without that code snippet, so either it's wrong or it's interacting with something wrong. Where should I be putting it, ideally?

UPDATE: I answered my own question by moving the script down a few chunks and now no more errors! The map pops up at the appropriate time... Except my hotspots aren't working. At first they were half working but in the wrong places (in a big lump in the middle), so I changed the coordinates (nothing else), and now nothing at all responds, even though I'm positive that they're correct. I tried (Upper Left xpos, UL ypos, Lower Right xpos, LR ypos) AND (UL xpos, UL ypos, width, height) since different help/forum answers say different things, all relative to my 800x600 window, but nothing reacts? Once again I'm sure I'm making another silly mistake. D: Here's the code as it stands now:

Code: Select all

# The game starts here.

screen i_map:
    imagemap:
        auto "imagemap_%s.jpg"
       
        hotspot (150,140,224,34) action Return("store_m")
        hotspot (325,275,132,34) action Return("square_m")
        hotspot (175,340,200,34) action Return("inn_m")
        hotspot (540,340,177,34) action Return("castle_m")
And then:

Code: Select all

label imap:

window hide None
call screen i_map
window show None

if _return == "store_m":
    m "You chose the store."

elif _return == "square_m":
    m "You chose the square."
        
elif _return == "inn_m":
    m "You chose the inn."

elif _return == "castle_m":
    m "You chose the castle."
Update again: Solved everything thanks to the code snippet in this post.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]