Persistent in game navigation menu

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
sgtslats
Newbie
Posts: 2
Joined: Sun May 20, 2018 6:18 pm
Contact:

Persistent in game navigation menu

#1 Post by sgtslats » Sun May 20, 2018 6:27 pm

Hi. I'm really new to Ren'Py and Python but decided to jump into the deep end. I've got the basics down on assembling a VN with Ren'Py.

Now I want to try something different. I'd like to have a persistent menu at the top of the screen that shows available rooms the player can go to and, upon clicking a room, the player is brought there and the menu remains. I've gone down the rabit hole for Ren'Py documentation but can't get anything to work properly. I attempted with imagebuttons, imagemaps, textbuttons but I can't get anything to work properly. Are there any tutorials or walkthroughs out there specific to something like this? Everything I find refers to separate menu screens. I can't find anything about persistent, on-screen menus.

Any tips or documentation that anyone could supply would be much appreciated.

kivik
Miko-Class Veteran
Posts: 784
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Persistent in game navigation menu

#2 Post by kivik » Mon May 21, 2018 5:21 am

Hey, welcome to the fun of Renpy and the forum!

First of all, I'd avoid the term "persistent" because persistent means something very specific in Renpy - it's to do with persistent variable / information that persists across play sessions. So it'd risk confusing the topic of conversation if you use it.

Secondly, menu is also a specific term in Renpy as well XD! Specifically the game menu, so best to avoid using that term as well unless that's what you're referring to.

What you're describing is kind of called a "HUD" - heads up display, though there's probably a better term that others can give you.


Now, whilst you're new to Renpy and Python: how experienced are you with programming in general? I ask because room navigation isn't something that Renpy has out of the box and you'd have to code all of that from scratch - so I wanted to make sure you exercise some caution before jumping that far into the deep end with no experience. If you have experience and are comfortable with creating a navigation system in your head already, then it shouldn't be a problem at all :)


The way Renpy shows these addition elements in the game: buttons, clickable stuff, is through Screens. But there's something else you need to be aware of - interactions. Renpy basically will constantly move forward and eat up your CPU processes if until it hits an interaction or game end, this confused the hell out of me when I first started.

So if you were to make a screen, and then show the screen and do nothing else - the game will just end as soon as it starts:

Code: Select all

screen test:
    text "Hello world"

label start:
    show screen test
To trigger an interaction with a screen, you need to call it:

Code: Select all

call screen test
That will show the screen, and wait for input. After input, it'll go away. That's all well and good but when you call a screen, it interrupts the normal game interactions - i.e. dialogues. And you can't call a screen and show dialogues at the same time - it's one or another.

And that's what show screen is for: showing a screen means it's always available even during dialogues - so you can click on the little button whilst someone is talking on screen.

There's only one problem: you mentioned your button is going to let people navigate around rooms in your game, so if you show the button during conversations, your player could in theory escape to another room mid-scene.


So, you need to think carefully about how to approach your HUD / UI. You can either use show screen and disable the button (through a variable and the If() action https://www.renpy.org/doc/html/screen_actions.html#If), or call the screen after a scene with dialogues is over.

I suspect you're actually interested in the second scenario - it's what I use in my game. Just a heads up, you'd need to put the call screen statement inside a loop so that it'll keep showing until you've finished the "navigation" portion of the game loop by triggering another scene.


Hope the above makes some sort of sense, if not, I'll try and link more resources.

sgtslats
Newbie
Posts: 2
Joined: Sun May 20, 2018 6:18 pm
Contact:

Re: Persistent in game navigation menu

#3 Post by sgtslats » Mon May 21, 2018 9:41 am

WOW! Thanks Kivik! This cleared everything up for me and gave me a lot to think about. I'm fairly proficient in Java and have only just started tackling Python a couple months ago.

I kept seeing people refer to "Screens" but didn't understand how they were implemented or how they behave. Thanks so much for clearing this up for me. I'm at work right now but intend to play around with this further tonight.

Post Reply

Who is online

Users browsing this forum: No registered users