Imagemap not showing up.

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
Bum_McFluff
Regular
Posts: 26
Joined: Sat Aug 18, 2018 8:15 pm
Contact:

Imagemap not showing up.

#1 Post by Bum_McFluff » Fri Feb 21, 2020 12:03 am

I got the following code from the Cookbook, from the "A simple Navigation map tutorial".

Code: Select all

screen planets: #Preparing the imagemap
    imagemap:
        ground "planets.jpg"
        hover "planets-hover.png"
        
        hotspot (62, 399, 90, 91) clicked Jump("mercury")
        hotspot (227, 302, 141, 137) clicked Jump("venus")
        hotspot (405, 218, 164, 118) clicked Jump("earth")
        hotspot (591, 78, 123, 111) clicked Jump("mars")

# The game starts here.
label start:
    "This is an imagemap tutorial."
    jump solar_system

label solar_system:
    call screen planets #Displaying the imagemap

label mercury:
    "It is Mercury."
    jump solar_system

label venus:
    "It is Venus."
    jump solar_system

label earth:
    "It is Earth."
    jump solar_system
    
label mars:
    "It is Mars."
    jump solar_system
I then altered it to reflect what I wanted to do, which was the player could select the gender of the character, and this would be recorded in Ren'Py. I want to assign an image to whichever choice the player makes.

Code: Select all

label selection:
scene selection
    
screen selection:
    imagemap:
        ground "selection_00.png"
        hover "selection_hover.png"
        
        hotspot (273, 359, 450, 542) $ gender = "Male"
        hotspot (273, 710, 450, 880) $ gender = "Female"

jump nameselection

label nameselection:
After this it is supposed to go to another screen where you can input your name. Previously I simply had a menu:

Code: Select all

##    menu:
##        'Male':
##            $ gender = "Male"
##        'Female':
##            $ gender = "Female"
##            jump nameselection
My original menu worked fine. I have currently it turned off (as seen above) until I can get the new code working. However, upon launching Ren'Py, it simply ignores the new code and goes straight to label nameselection:. It does this even if I leave the clicked Jump("mercury") stuff in it (with the proper label name.

So what am I doing wrong, or is the code out of date or something similar?
What, spy on our spy as he searches for their spy? Why not, sounds rather like fun.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 644
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1
Projects: Defenders of Adacan Part 2
Deviantart: pekj
itch: per-k-grok
Location: Sverige
Contact:

Re: Imagemap not showing up.

#2 Post by Per K Grok » Fri Feb 21, 2020 2:00 am

Bum_McFluff wrote:
Fri Feb 21, 2020 12:03 am


So what am I doing wrong, or is the code out of date or something similar?[/b]
You are not following the model in the cookbook example.

In that example you first define the screen.

Then your game code starts, and in that code the screen is called.


What you are doing is that you define the screen in the game code and never call it. This is not the same thing.

If you follow the cookbook code you would get something like this (updated clicked to action)

Code: Select all


############################# defining screen
screen selection:
    imagemap:
        ground "selection_00.png"
        hover "selection_hover.png"
        
        hotspot (273, 359, 450, 542) action Jump("MaleChoice")
        hotspot (273, 710, 450, 880) action Jump( "FemaleChoice")


############################ start gamecode

label start:
    jump selection
    
label selection:
   call screen selection       ############## this calls the screen
    
label MaleChoice:
    $ gender = "Male"
    jump picked
    
label FemaleChoice:
    $ gender = "Female"
    jump picked    
    
label picked:
    "You chose: [gender]"
    return 

Image Visual Story Telling, DeviantArt Group for animations, comics, games and illustrations https://www.deviantart.com/acgi

User avatar
Bum_McFluff
Regular
Posts: 26
Joined: Sat Aug 18, 2018 8:15 pm
Contact:

Re: Imagemap not showing up.

#3 Post by Bum_McFluff » Fri Feb 21, 2020 7:38 pm

Per K Grok wrote:
Fri Feb 21, 2020 2:00 am
Bum_McFluff wrote:
Fri Feb 21, 2020 12:03 am

So what am I doing wrong, or is the code out of date or something similar?[/b]
You are not following the model in the cookbook example.

In that example you first define the screen.

Then your game code starts, and in that code the screen is called.

What you are doing is that you define the screen in the game code and never call it. This is not the same thing.

If you follow the cookbook code you would get something like this (updated clicked to action)
I have removed your code form this post to reduce the size.

Thanks for your quick response. However, it is still not working as I want it. Now this might be me trying to do too much before the game starts, but after the MaleChoice/FemaleChoice part, I don't want to go to game start, but make a few other choices, such as name selection. However, even if this is an okay concept, the whole imagemap is still not showing up at all. Upon launching the game, it goes straight to my name selection.

Code: Select all

label selection:
scene selection

# This is an attempt to get an image map working
screen selection:
    imagemap:
        ground "selection_00.png"
        hover "selection_hover.png"
        
        hotspot (273, 359, 450, 542) action Jump("MaleChoice")
        hotspot (273, 710, 450, 880) action Jump("FemaleChoice")

##jump nameselection

##menu:
##    'Male':
##        $ gender = "Male"
##    'Female':
##        $ gender = "Female"
##        jump nameselection

label MaleChoice:
    $ gender = "Male"
    jump nameselection

label FemaleChoice:
    $ gender = "Female"
    jump nameselection

label nameselection:
    scene selection2
    
    define pov = Character("[povname]")

python:
    agentname = renpy.input("Enter your agent ID")
    agentname = agentname.strip()

    if not agentname:
         agentname = "Bluefox"

python:
    povname = renpy.input("Choose your cover name")
    povname = povname.strip()

    if not povname:
         povname = "Pat Smith"
I left the alternative menu that I was using, which did work, just in case it is helpful at all.
What, spy on our spy as he searches for their spy? Why not, sounds rather like fun.

User avatar
Bum_McFluff
Regular
Posts: 26
Joined: Sat Aug 18, 2018 8:15 pm
Contact:

Re: Imagemap not showing up.

#4 Post by Bum_McFluff » Mon Feb 24, 2020 6:33 pm

Ok, so now I 've got this:

Code: Select all

label selection:

# This is an attempt to get an image map working
screen genderselection:
    imagemap:
        ground "selection_00.png"
        hover "selection_hover.png"
        
        hotspot (273, 359, 450, 542) action Jump("MaleChoice")
        hotspot (273, 710, 450, 880) action Jump("FemaleChoice")

label genderselection:

label MaleChoice:
    $ pc_gender = "Male"
    jump nameselection

label FemaleChoice:
    $ pc_gender = "Female"
    jump nameselection

label nameselection:
    scene selection2
    
    define pov = Character("[povname]")

python:
    agentname = renpy.input("Enter your agent ID")
    agentname = agentname.strip()

    if not agentname:
         agentname = "Bluefox"

python:
    povname = renpy.input("Choose your cover first name")
    povname = povname.strip()

    if not povname:
         povname = "Jay"

python:
    povname2 = renpy.input("Choose your cover surname")
    povname2 = povname2.strip()

    if not povname2:
         povname2 = "Smith"

o "Welcome agent [agentname]!"
o "Your cover name is {i}[povname] [povname2]{/i}!"

python:
    cityname = "Darkham"
    maidname = "Selena"

jump story_intro
As far as I can see, I've got all the required bits in place. The only thing that I can see different is that in the original code, after the hotspots it goes to label gamestart: But I don't want to start the game yet, I have more things for the player to select. Is that the issue? Does it need to go to gamestart? Is what I want beyond the scope of this particular code?
I'm not suggesting this code is bad, but maybe I'm asking too much of it.

I also want to have a map of the place be accessible to the player later, and as far as I can tell, an imagemap is the only way to do that. But if my thoughts above on the gamestart issue are correct, does that mean I can't have more than one imagemap in a game?
What, spy on our spy as he searches for their spy? Why not, sounds rather like fun.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 2850
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: Imagemap not showing up.

#5 Post by Imperf3kt » Mon Feb 24, 2020 6:41 pm

This isn't what's causing your issue, but your indentation is not correct, though how you have it will work...

https://www.renpy.org/doc/html/label.html

Your python sections should be in the label, but you have them on the same level as your labels.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Twitter

User avatar
Bum_McFluff
Regular
Posts: 26
Joined: Sat Aug 18, 2018 8:15 pm
Contact:

Re: Imagemap not showing up.

#6 Post by Bum_McFluff » Mon Feb 24, 2020 7:04 pm

Imperf3kt wrote:
Mon Feb 24, 2020 6:41 pm
This isn't what's causing your issue, but your indentation is not correct, though how you have it will work...

https://www.renpy.org/doc/html/label.html

Your python sections should be in the label, but you have them on the same level as your labels.
But the python sections are working. I can enter the names required, and it shows up later in text with the appropriate [povname] code for example.

Also, I don't understand the label/labels reference. Do yo mean that all of the python stuff in my code should be moved until it is underneath label genderselections: ?

Also the launcher isn't showing me any indentation issues. If it doesn't show me an issue, I have no way of knowing that I have one (aside from things not working).

Additional

I went to this page viewtopic.php?t=46229 by jane_runs_fast memberlist.php?mode=viewprofile&u=40377

which cleared up some points for me. It now works, except that in following her instructions and changing my initial

Code: Select all

screen genderselection:
to

Code: Select all

screen navigation():
it completely takes over from the main menu. If I change it back to

Code: Select all

screen genderselection:
and include the (), the imagemap still doesn't show up.

So now it seems that I just need the initial name: screen whatname in order to get it to appear without taking over completely.
What, spy on our spy as he searches for their spy? Why not, sounds rather like fun.

User avatar
gas
Miko-Class Veteran
Posts: 624
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Imagemap not showing up.

#7 Post by gas » Mon Feb 24, 2020 11:47 pm

Code: Select all

label whatever:
    python:
        # do python stuff
    call screen any_screen()
    # bla bla bla

########### The end of the script or wherever you want
screen any_screen():
    # content of the screen
The launcher throw no errors, but that doesn't mean the code can't throw errors and corrupt the script later, generating a lot of issues. Like your case.
Is not wrong to state a single python block outside a label... but your python code HAD to.
Don't try to do more than you know. Try to begin with something you know already. So, for example, an horrible demo of a standard VNL that you'll never release. Such indentations (and how blocks are managed) are the base of Renpy, without them you don't shortcut development time at all.
10 ? "RENPY"
20 GOTO 10

RUN

Post Reply

Who is online

Users browsing this forum: Google [Bot], MaydohMaydoh