Custom Imagemap Trouble

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
vaanknight
Regular
Posts: 118
Joined: Sun Mar 28, 2010 6:01 pm
Completed: Happy Weird-Day! How a freckled fairy can save your world (Or get more freckles in the process...)"
Projects: Nameless 2D Fighting Game
Contact:

Custom Imagemap Trouble

#1 Post by vaanknight » Mon Jul 12, 2010 4:45 pm

Ok guys, I've got this problem, I count on your witty selves to solve it:

I made an imagemap so upon clicking on each button plays a tune and shows an image. It does as it's supposed to, but it jumps straight from the music start and the image shown to another scene, which is found in a completely different label.

The code for my imagemap menu is something like this:

Code: Select all

    $ result = renpy.imagemap("ground.jpg", "hover.png", [
        (30, 130, 170, 170, "button_one"),
        (30, 180, 170, 220, "button_two"),
        (30, 230, 170, 270, "button_three"),
        ]
the code for those buttons is like this:

Code: Select all

      
    if result == "button_one":
        play music "randomtuneone.ogg"
        show randomimageone with dissolve

      
    elif result == "button_two":
        play music "randomtunetwo.ogg"
        show randomimagetwo with dissolve

      
    elif result == "button_three":
        play music "randomtunethree.ogg"
        show randomimagethree with dissolve
So, what do I add so the music plays, the image shows, and the screen stays in the imagemap menu as it is without jumping anywhere? I want the user to be able to click on a button, listen to the music and watch the image, and still be able to click on another button whenever they want.

Any comment or idea is welcome, TY!
Image

User avatar
Alex
Lemma-Class Veteran
Posts: 2494
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Custom Imagemap Trouble

#2 Post by Alex » Tue Jul 13, 2010 4:35 am

Well, if you need to show smth over imagemap, you should use <ui.imagemap> rather than <renpy.imagemap>.
And if you need to use this imagemap to show images again and again you should make a kind of loop (show imagemap - player clicks - show image - go back to imagemap).
So, my example is

Code: Select all

init:
    $ pic = Null () # picture to show (nothing at the beginning)
    $ tune = None # music to play

label start:
    scene black

label imagemap:
    $ ui.imagemap ("ground.jpg", "hover.png", [
        (30, 130, 170, 170, "button_one"),
        (30, 180, 170, 220, "button_two"),
        (30, 230, 170, 270, "button_three"),
        ])

    play music tune
    $ ui.image (pic, xpos = 500, ypos = 400)
    $ renpy.transition (dissolve)
    
    $ result= ui.interact()

    if result == "button_one":
        $ tune = "randomtuneone.ogg"     # set the music to play
        $ pic = "randomimageone.png"     # set the picture to show (uses file name)   
        jump imagemap
      
    elif result == "button_two":
        $ tune = "randomtunetwo.ogg"
        $ pic = "randomimagetwo.png"
        jump imagemap

    elif result == "button_three":
        $ tune = "randomtunethree.ogg"
        $ pic = "randomimagethree.png"
        jump imagemap
* don't forget to make button to leave this imagemap

http://lemmasoft.renai.us/forums/viewto ... ton#p84986
http://www.renpy.org/wiki/ui.image
http://www.renpy.org/wiki/renpy/doc/ref ... transition
Last edited by Alex on Wed Jul 14, 2010 12:58 am, edited 1 time in total.

User avatar
KimiYoriBaka
Miko-Class Veteran
Posts: 636
Joined: Thu May 14, 2009 8:15 pm
Projects: Castle of Arhannia
Contact:

Re: Custom Imagemap Trouble

#3 Post by KimiYoriBaka » Tue Jul 13, 2010 1:13 pm

just thought I'd point out that both your scripts include

Code: Select all

$ ui.imagemap ("ground.jpg", "hover.png", [
        (30, 130, 170, 170, "button_one"),
        (30, 180, 170, 220, "button_two"),
        (30, 230, 170, 270, "button_three"),
        ]
which not only has an extra comma in the brackets, it doesn't have a closing parenthesis at the end of of the statement to match the very first one. I don't if this typo was in just the post or in your real script, but this seems like it's begging for errors.

User avatar
PyTom
Ren'Py Creator
Posts: 15474
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Custom Imagemap Trouble

#4 Post by PyTom » Tue Jul 13, 2010 1:58 pm

The extra comma is legal in Python, which considers:

[ 1, 2, 3 ]

and

[ 1, 2, 3, ]

to be equivalent. In fact, there's one place where the comma is actually required: (1) is just 1, while (1,) is a 1-tuple containing 1.

Also, ui.imagemap was renamed ui.imagemap_compat in 6.11.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
vaanknight
Regular
Posts: 118
Joined: Sun Mar 28, 2010 6:01 pm
Completed: Happy Weird-Day! How a freckled fairy can save your world (Or get more freckles in the process...)"
Projects: Nameless 2D Fighting Game
Contact:

Re: Custom Imagemap Trouble

#5 Post by vaanknight » Tue Jul 13, 2010 2:03 pm

Oh right, xD the syntax. Sorry about the cheesy example, I just made up that script out of my memory because I wasn't on my PC the day I wrote that, but the real deal is written as it should. Thank you all, I will try out that solution! d^-^b
Image

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Karrion, Pandar