Ren'Py is there any command to see all the variables in renpy?

tossler

Member
Jul 1, 2017
396
246
dir() just shows me the first 10 variables in alphabetical order, followed by "..."
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,968
16,222
My god... please no, do not use dir(), it will present you tons of variables, with less than 5% of them being related to the game, and even fewer being effectively significant.

If really you want to see the variables, either use the developer menu, a dedicated tool, or the attached file ; it add a command named "variables" to the console, that will display what the developer "variable viewer" would have shown.
 

C$Money

Member
Oct 15, 2017
105
25
My god... please no, do not use dir(), it will present you tons of variables, with less than 5% of them being related to the game, and even fewer being effectively significant.

If really you want to see the variables, either use the developer menu, a dedicated tool, or the attached file ; it add a command named "variables" to the console, that will display what the developer "variable viewer" would have shown.
How do i implement this command?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,968
16,222
How do i implement this command?
What do you mean by "implement" ?

You download the file, and put it in the "game" directory, nothing more. Of course, you need to do this before you start the game.
 

ZenoMod

Active Member
Nov 12, 2022
926
1,085
My god... please no, do not use dir(), it will present you tons of variables, with less than 5% of them being related to the game, and even fewer being effectively significant.

If really you want to see the variables, either use the developer menu, a dedicated tool, or the attached file ; it add a command named "variables" to the console, that will display what the developer "variable viewer" would have shown.
-------------------------------------------------------------------------------------------------------------------------
EDITED because I had inverted the meaning of escaped and unescaped, as noticed in this reply.
strikethrough : ...deleted text
red : .................inserted text
-------------------------------------------------------------------------------------------------------------------------

That's great! Thanks!

I have a minor issue with strings containing unicode characters not correctly escaped printed as they are, but escaped instead.

Actually I think it's an issue of Ren'Py console itself, because according to documentation to escape unicode characters (rather than printing them as they are, which is the default) the user of the console should simply give the command escape to enable escaping, and unescape to set it back the default behaviour. But while, for instance, command long actually works as per documentation to have console output unabridged, commands escape and unescape seems to do nothing.

For instance in game "Bright Past" there's a variable named waiting containing cyrillics.
If I simply call it form console, it's printed unescaped (nonetheless escapeunescape being active).

To bypass this issue in the console I've found the workaround of giving the inline python command
$ print(waiting)
and this prints on the console the correctly unescaped cyrillics (see screenshot)
Escaping Unicode.jpg

I was wondering if you could suggest me a similar workaround to let unicode characters being unescaped also using your variables command.

For your convenience i write here the unescaped and unescaped string so they can be used by copy&paste
Code:
waiting: u'\u041f\u043e\u0434\u043e\u0436\u0434\u0430\u0442\u044c \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439'

Подождать развития событий

I have tryed adding the unicode u prefix here, but nothing changes.
Escaping Unicode 2.jpg

Any suggestions? Thanks in avance!
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,968
16,222
To bypass this issue in the console I've found the workaround of giving the inline python command
$ print(waiting)
and this prints on the console the correctly escaped cyrillics (see screenshot)
Hmm, it's the opposite, the result of print is the not escaped string.


I have tryed adding the unicode u prefix here, but nothing changes.
Because, to simplify, the 'u' prefix only apply at preprocessing time.
This being said, to directly have the unescaped version, just remove the repr:
print ( "{}: {}".format( e, getattr( store, e ) ) ).

But depending on the version of Ren'Py, I don't guaranty that it will not be breaking in a way or another.
I included the repr because I know by experience that some dev are really dirty, and few time I have "broken screens" (just relatively broken of course), because of really weird strings.
 

ZenoMod

Active Member
Nov 12, 2022
926
1,085
This being said, to directly have the unescaped version, just remove the repr:
print ( "{}: {}".format( e, getattr( store, e ) ) ).

But depending on the version of Ren'Py, I don't guaranty that it will not be breaking in a way or another.
I included the repr because I know by experience that some dev are really dirty, and few time I have "broken screens" (just relatively broken of course), because of really weird strings.
Well... It works like charm, at least with the game "Bright Past": just what I needed, thank you very much! :)
Unicode_OK.jpg

Do you know if it is somehow possible to define a custom console command which takes a parameter?
Because - for now - in order to print only the variables beginning with "npc" I have hardcoded such a filter changing your
Code:
if e.startswith( "_" ): continue
to
Code:
if e.startswith( "_" ): continue
if not e.startswith( "npc" ): continue

It would be cool if the user coud type variables <arg1> and this argument being passed to your code, so I could update my tweak to
Code:
if e.startswith( "_" ): continue
if not e.startswith( args[0] ): continue
Where, clearly, the c#-like token args[0] should be substituted with the proper parameter name used by Ren'Py, if Ren'Py Console is able to pass it to the code like c# does... I tryed googling, but I found nothing. :(
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,968
16,222
Do you know if it is somehow possible to define a custom console command which takes a parameter?
Normally you should find the arguments in the l variable ; the one declared as argument for
varList
. But it's late (past midnight), still too hot (past 30°C), so I don't really remember if it's literal arguments, a tuple, or a lexer object.
 
  • Like
Reactions: ZenoMod

ZenoMod

Active Member
Nov 12, 2022
926
1,085
Normally you should find the arguments in the l variable ; the one declared as argument for
varList
. But it's late (past midnight), still too hot (past 30°C), so I don't really remember if it's literal arguments, a tuple, or a lexer object.
It is indeed a Lexer object containing the arguments: thanks for your hint that helped me achieve my purpose! :)

In the attachment a tweak to your variables Console commad.

It accepts an optional <filter> parameter.
If called from Console with no parameter, it lists all variables.
If called from Console with a <filter> parameter, it lists only those variables containing <filter> as a substring of their name.
(If called with more than one parameter, the first parameter is used as <filter> and the other parameters are discarded.)

I decided to drop my file here because I think it could be useful for beginners like me, and for feedback should I have made any mistakes.

You don't have permission to view the spoiler content. Log in or register now.
 
  • Like
Reactions: anne O'nymous