Ren'Py Script/code to output labels/scenes onto a textfile?

m24nub

Newbie
Aug 25, 2017
29
2
Hi, does anyone know a script/code I can use to output labels onto a text file? Ideally, each label is separated by a new line. The way each label is listed using renpy.get_all_labels() is impossible to use and would like them printed on a text file so I can search them more easily. Thanks!
 

AnimeKing314

Giant Perv
Game Developer
Jun 28, 2018
395
605
I don't know if a script already exists but perl is a great language for text processing and uses regex so it would be pretty easy to create a perl script to do this
 

m24nub

Newbie
Aug 25, 2017
29
2
I don't know if a script already exists but perl is a great language for text processing and uses regex so it would be pretty easy to create a perl script to do this
Unfortunately, I have no programming experience :( Ideally, I would be able to place the code in a script that I can place it in any Ren'Py game and export the labels
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,971
16,229
Hi, does anyone know a script/code I can use to output labels onto a text file? Ideally, each label is separated by a new line. The way each label is listed using renpy.get_all_labels() is impossible to use and would like them printed on a text file so I can search them more easily. Thanks!

Put this in a "myAllLabels.rpy" file:
Code:
init python:
    def myAllLabels():
        FH = open( renpy.os.path.join( config.basedir, 'AllLabels.txt' ), "a" )
        for l in sorted( renpy.get_all_labels() ):
            FH.write( "{}\n".format( l ) )
        FH.close()

    config.console = True
Put the "myAllLabels.pry" file in the "[path to the game]/game" directory.

When the game is running, open the console (SHIFT]+o) and type myAllLabels().


Be aware that you'll also have all the labels used internally by Ren'py.
 

m24nub

Newbie
Aug 25, 2017
29
2
Put this in a "myAllLabels.rpy" file:
Code:
init python:
    def myAllLabels():
        FH = open( renpy.os.path.join( config.basedir, 'AllLabels.txt' ), "a" )
        for l in sorted( renpy.get_all_labels() ):
            FH.write( "{}\n".format( l ) )
        FH.close()

    config.console = True
Put the "myAllLabels.pry" file in the "[path to the game]/game" directory.

When the game is running, open the console (SHIFT]+o) and type myAllLabels().


Be aware that you'll also have all the labels used internally by Ren'py.
Thanks! I merged some of your code with 79flavors and found the perfect solution:

Code:
  f=open( renpy.os.path.join( config.basedir, '_Labels.txt' ), "w")
  for i in sorted(renpy.get_all_labels()): f.write("{}:\n".format(i))
  f.close()
Do you know why I don't get all the variables when I replace renpy.get_all_labels() with dir() ?
 
Last edited: