How to call this map from a menu button

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
Sepharius
Newbie
Posts: 5
Joined: Fri Aug 25, 2017 10:14 am
Contact:

How to call this map from a menu button

#1 Post by Sepharius »

I'm currently learning how to place this navigation map, but I'm experiencing a few errors.

1. How do I stop it replacing my start menu? When I launch the game, it goes straight to this map.
2. How can I launch it from a map button?

Thanks.

User avatar
vollschauer
Veteran
Posts: 231
Joined: Sun Oct 11, 2015 9:38 am
Github: vollschauer
Contact:

Re: How to call this map from a menu button

#2 Post by vollschauer »

It shouldn't replace you start menu, then you did something wrong. Where did you place this code?

Sepharius
Newbie
Posts: 5
Joined: Fri Aug 25, 2017 10:14 am
Contact:

Re: How to call this map from a menu button

#3 Post by Sepharius »

A line of the code says "# The game starts here." so I literally placed it there.
Was that wrong?

User avatar
RicharDann
Veteran
Posts: 286
Joined: Thu Aug 31, 2017 11:47 am
Contact:

Re: How to call this map from a menu button

#4 Post by RicharDann »

I can't imagine how would that replace the start menu, but I think that to avoid this you should place the planets screen and the solar_system labels in a .rpy file other than the script (you can make one with editra).

As for calling the map from a button, it depends on how you want to handle the navigation. You could place that button on a menu (like the game menu) and give it a Jump action so the game jumps to the solar_system label in your other file.

In your script.rpy file:

Code: Select all


#This screen is just for testing, you should place this button in your game menu or where you want to.
screen navigation_map_button():
    textbutton "Navigation" action Jump('solar_system')
    
label start:

    "Here we show the test button"

    show screen navigation_map_button() 
    
    "Click it to launch the navigation map."
In a different file, say you name it navigation.rpy:

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")
    
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

# And the rest of planets or locations go below here
The most important step is always the next one.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]