Imagemap Refuses To Work, noob w/Python [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
rjayne
Newbie
Posts: 15
Joined: Wed Feb 25, 2015 7:48 am
Contact:

Imagemap Refuses To Work, noob w/Python [Solved]

#1 Post by rjayne » Wed Feb 25, 2015 7:58 am

Okay, so I am seriously losing my mind here, which is why I thought I'd stop from stabbing a passerby and just go ahead and ask. I'll admit, I only started with Ren'py today, but I have a background in scripting logic so I figured I'll get it sooner or later. Unfortunately I'm finding it a little hard to find exactly what I need in the available documentation. Everything else is working fine, except with my attempt at an imagemap.

Okay, so this is my code. I simplified the co-ordinates for the hover as much as possible, and nothing.

Code: Select all

$ result = renpy.imagemap("gui/ground.png", "gui/hover.png", [
    (0, 760, 200, 200, "d1"), 
    (200, 760, 200, 200, "d2"), 
    (0, 560, 200, 200, "d3"), 
   (200, 560, 200, 200, "d4")
   ], focus="imagemap" )
    
    if result == "d1":
       "d1"
    elif result == "d2":
        "d2"
    elif result == "d3":
        "d3"
    else:
        "d4"
likewise, the map is stupid simple so I can get this to work, and nothing.

Ground http://i.imgur.com/e0SKBRm.png
Hover http://i.imgur.com/LONy5Yx.png

If anybody can put me out of my misery at what silly thing I'm missing here, I'd be eternally grateful. Thank you.

Edit: to be clear the script is firing, the ground image appears, and then I cannot highlight/select anything to advance.
Last edited by rjayne on Wed Feb 25, 2015 8:09 pm, edited 1 time in total.

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

Re: Imagemap Refuses To Work, noob w/Python

#2 Post by philat » Wed Feb 25, 2015 1:38 pm

Never tried using an imagemap as a python statement, but comparing with this: http://www.renpy.org/wiki/renpy/doc/ref ... y.imagemap

Don't know what the focus=imagemap does, also the indentation for your if statements seems wonky. Throwing it out there in case it helps.

User avatar
rjayne
Newbie
Posts: 15
Joined: Wed Feb 25, 2015 7:48 am
Contact:

Re: Imagemap Refuses To Work, noob w/Python

#3 Post by rjayne » Wed Feb 25, 2015 7:12 pm

Thank you for the response. I've tried removing the focus=imagemap, since it's only sometimes included on the few instances of image maps I found online, and sometimes not (such as in the example you posted). It unfortunately doesn't make a difference. It is the section of code I wasn't sure about.

I also tried removing the if statement and reformatting but didn't have much luck with either. What really melts the brain is the rest is essentially exactly what is posted in the documentation.

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

Re: Imagemap Refuses To Work, noob w/Python

#4 Post by philat » Wed Feb 25, 2015 7:30 pm

I have no idea why it doesn't work. Is there a particular reason you're going the python route as opposed to screen language?

User avatar
rjayne
Newbie
Posts: 15
Joined: Wed Feb 25, 2015 7:48 am
Contact:

Re: Imagemap Refuses To Work, noob w/Python

#5 Post by rjayne » Wed Feb 25, 2015 7:32 pm

That would be a total lack of experience to be honest. If it does the same thing (passes out a result I can then use) I would very much appreciate the method to popping up a working imagemap with screen language.

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

Re: Imagemap Refuses To Work, noob w/Python

#6 Post by philat » Wed Feb 25, 2015 7:42 pm

Screen language is way easier than the ui or python equivalents, at least in my experience.

Code: Select all

screen testmap():
    imagemap:
        ground "img/ground.png" 
        hover "img/hover.png"

        hotspot (0, 760, 200, 200) action Return("d1")
        hotspot (200, 760, 200, 200) action Return("d2")
        hotspot (0, 560, 200, 200) action Return("d3")
        hotspot (200, 560, 200, 200) action Return("d4")

label start:
    call screen testmap ## the value from the imagemap is returned to the variable _return by default

    if _return == "d1":
       "d1"
    elif _return == "d2":
        "d2"
    elif _return == "d3":
        "d3"
    else:
        "d4"

User avatar
rjayne
Newbie
Posts: 15
Joined: Wed Feb 25, 2015 7:48 am
Contact:

Re: Imagemap Refuses To Work, noob w/Python

#7 Post by rjayne » Wed Feb 25, 2015 8:08 pm

Thank you very much, that worked without any problems. I can continue without pulling anymore hair out! Heh.

I'll mark this as solved.

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot]