Page 1 of 1

Imagemap not showing up.

Posted: Fri Feb 21, 2020 12:03 am
by Bum_McFluff
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?

Re: Imagemap not showing up.

Posted: Fri Feb 21, 2020 2:00 am
by Per K Grok
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 


Re: Imagemap not showing up.

Posted: Fri Feb 21, 2020 7:38 pm
by Bum_McFluff
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.

Re: Imagemap not showing up.

Posted: Mon Feb 24, 2020 6:33 pm
by Bum_McFluff
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?

Re: Imagemap not showing up.

Posted: Mon Feb 24, 2020 6:41 pm
by Imperf3kt
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.

Re: Imagemap not showing up.

Posted: Mon Feb 24, 2020 7:04 pm
by Bum_McFluff
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.

Re: Imagemap not showing up.

Posted: Mon Feb 24, 2020 11:47 pm
by gas

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.