Making a pop-up screen to show statistics

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
willanik
Regular
Posts: 26
Joined: Fri Mar 24, 2017 7:44 pm
Contact:

Making a pop-up screen to show statistics

#1 Post by willanik » Sun Feb 09, 2020 8:14 pm

Hi,

I want to add a pop up screen to my game to show game statistics. Ideally with a button on the main game screen that, when pressed, opens a screen where I can list the player’s variables and show the current value for each variable.

Unfortunately I don’t know what to do! I have looked at a few other threads and tried to use them as a guide but without success.

I assume that I need to define the button (called “Player stats”) and the screen. The screen will list variables like health, strength, agility, courage.

The button should be available on the top right of the main game screen ( and I can show it or hide it via ‘show’ and 'hide'). Clicking on it would open the stats screen. Ideally the pop-up stats screen would have a ‘close’ button on it.

Can someone point me towards an example I might be able to adapt, or give me a start on the text I need?

Thanks in advance for your thoughts and suggestions.

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

Re: Making a pop-up screen to show statistics

#2 Post by gas » Mon Feb 10, 2020 10:01 am

You can come easily with such thing by inspecting a bit the Screen Language Actions and Functions section of the docs.
The easiest way is to add another button to the quick menu, located where you want. This button use a Show("stat_panel") action.
Then you create another screen, the "stat_panel" (with all data you want to show), with a button that Hide("stat_panel").

Ask if you want exact code, is a very easy thing to do anyway.
10 ? "RENPY"
20 GOTO 10

RUN

willanik
Regular
Posts: 26
Joined: Fri Mar 24, 2017 7:44 pm
Contact:

Re: Making a pop-up screen to show statistics

#3 Post by willanik » Mon Feb 10, 2020 9:04 pm

Thanks for replying gas. Unfortunately I have never used quick menu and I don't know where to start. I thought I could copy from a thread like this - viewtopic.php?t=40657 but it all looks strange to me and I think I will just get myself into trouble :(

I appreciate your offer to do some code. If you could do something simple for me as a start I would be very grateful and would then try to "personalize" it myself.

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: Making a pop-up screen to show statistics

#4 Post by Per K Grok » Wed Feb 12, 2020 1:44 pm

willanik wrote:
Mon Feb 10, 2020 9:04 pm
Thanks for replying gas. Unfortunately I have never used quick menu and I don't know where to start. I thought I could copy from a thread like this - viewtopic.php?t=40657 but it all looks strange to me and I think I will just get myself into trouble :(

I appreciate your offer to do some code. If you could do something simple for me as a start I would be very grateful and would then try to "personalize" it myself.
It is always good to use the quote function to make the other person get a message. Otherwise your message might go unnoticed by the intended receiver.

Since I passed by and happened to have a piece of code I made for another thread that sort of fit in for what you want to do, I changed it a bit to be about stats and put it in here. I hope that it is of some use to you.

Code: Select all

default strength=5
default dexterity=3
default health=7



screen stats():
    textbutton "Player stats" action Show("playerstats"), Hide("stats")


screen playerstats():
    vbox:
        text "Strength: [strength]"
        text "Dexterity: [dexterity]"
        text "Health: [health]"
        textbutton "Close" action Show("stats"), Hide("playerstats")


label start:

    show screen stats

    pause
    return

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

willanik
Regular
Posts: 26
Joined: Fri Mar 24, 2017 7:44 pm
Contact:

Re: Making a pop-up screen to show statistics

#5 Post by willanik » Thu Feb 13, 2020 7:47 pm

quote="Per K Grok" post_id=524796 time=1581529460 user_id=43342]
It is always good to use the quote function to make the other person get a message. Otherwise your message might go unnoticed by the intended receiver.

Since I passed by and happened to have a piece of code I made for another thread that sort of fit in for what you want to do, I changed it a bit to be about stats and put it in here. I hope that it is of some use to you.

Code: Select all

default strength=5
default dexterity=3
default health=7



screen stats():
    textbutton "Player stats" action Show("playerstats"), Hide("stats")


screen playerstats():
    vbox:
        text "Strength: [strength]"
        text "Dexterity: [dexterity]"
        text "Health: [health]"
        textbutton "Close" action Show("stats"), Hide("playerstats")


label start:

    show screen stats

    pause
    return

[/quote]

Many thanks for this. It is a great start and I could add a second stats screen with other variables.
I need to learn how to position the textbuttons so they are not on top of each other! Then customize the statistics screens. I will give that a go next.

Thanks again to both responders.

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

Re: Making a pop-up screen to show statistics

#6 Post by Bum_McFluff » Fri Feb 14, 2020 10:04 pm

Many thanks for this. It is a great start and I want add a second stats screen with other variables.
I need to learn how to position the textbuttons so they are not on top of each other! Then customize the statistics screens. I will give that a go next.

Thanks again to both responders.
This is great. I also want to add a second, (maybe more) character's stats as well. I'm guessing it is a positional thing, so please post your results.
What, spy on our spy as he searches for their spy? Why not, sounds rather like fun.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], MaydohMaydoh