Ren'Py How to display values on the screen?

Keitaro420

Member
Apr 17, 2018
414
907
hello, I would like to ask how to show the value of a variable or a text in renpy.

I mean, a command that always shows a certain value at the top of the screen.

I seem to remember that it's possible but I don't remember how to do it. I think it was something like messages or warnings.

Thanks
 
  • Thinking Face
Reactions: Conquestus

Conquestus

Member
Modder
Jun 17, 2018
138
244
Well an easy way would be to lock it to the quick_menu:

for example
Code:
screen quick_menu():
    if showVarXActive == True:
        frame:
              xalign 0.98
              yalign 0.02
              vbox:
                   style_group "quick"
                   xalign 0.97
                   yalign 0.02
           
                   text "VarX : [varX]"

    if quick_menu:
        hbox:
            style_prefix "quick"

            [...]
If that's what you mean.
 
Last edited:
  • Like
Reactions: Keitaro420

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,559
2,175
If you're thinking of a permanent "in game" solution, you need a screen.
(I'll let someone else cover that one, because it's more work than I can be bothered with right now ;))

If however, you're wanting to show values of variables while you're testing... you can use watch
As long as you're launching/testing your game using the RenPy launcher, you should be able to access the system console (Press [SHIFT+O] while playing the game).

Just use the watch {variable} command to add your chosen variable to list shown on the screen.
Removing an entry just requires unwatch {variable}
Where {variable} is the name of one of your game's variables you want to display.

Then just use the exit command to return to the game.

You can also unlock the console for a live game using UnRen.
 
  • Like
Reactions: Keitaro420

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,132
14,815
(I'll let someone else cover that one, [...]
Looks like I'll be this someone.


Screens are automatically updated by Ren'py, therefore, if you define a screen that will show the value, then you'll have your solution. Technically there's no effective delay between each update of a screen, but there's at least one for each interaction, which guaranty to have a value that stay accurate.

As for the screen itself, there's many way to do it. It can be by using text substitution :
Code:
default myVar = 0

screen myScreen():
    text "value: [myVar]"
Directly have the value as text :
Code:
default myVar = 0

screen myScreen():
    text str( myVar )
Text replacement (the old way) :
Code:
default myVar = 0

screen myScreen():
    text "value: %s" % myVar
Or text replacement (the new way) :
Code:
default myVar = 0

screen myScreen():
    text ( "value: {}".format( myVar ) )


And finally to show the screen, you can add it to the list :
Code:
init python:
    config.overlay_screens.append( "myScreen" )
You can decide to show it or not, by changing the value of suppress_overlay (undocumented), but it will affect all the possible overlays (including the "quick menu").

You can simply show the screen and never hide it. It will stay on the screen unless you decide to effectively purge all the visible screens :
Code:
label start:
    show screen myScreen
Or you can include (with the screen statement) it to every screen that need to show the value :
Code:
screen myOtherScreen:
    [...]
    use myScreen
I once wrote a more complete answer regarding this, it's somewhere on this forum, but I don't really remember where.
 
Last edited: