Ren'py launch itself but with a different game directory?

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
User avatar
uyjulian
Regular
Posts: 128
Joined: Sun Mar 08, 2015 1:40 pm
Github: uyjulian
Contact:

Ren'py launch itself but with a different game directory?

#1 Post by uyjulian »

Okay, so how do I launch ren'py from within ren'py?

For example, my directory...

./game/
./game1/
./game2/
./game3/
./lib/
./renpy/
./renpy.app/
./renpy.exe
./renpy.py
./renpy.sh
./log.txt

So, when renpy is launched, it selects the game folder by looking to folder named by executable (except for folder ”renpy”); if executable begin with space or underscore, the folder without; game; data; and launcher/game. (ln163 ./renpy/bootstrap.py)

So then ren'py launches game folder ./game/ since it is the first valid folder to be in the list.

The folder ./game/ contain a chooser to select ./game1/, ./game2/, or ./game3/。

How do I launch ren'py from ren'py itself but forcing a different game directory?

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Ren'py launch itself but with a different game directory

#2 Post by PyTom »

Here's the code from the launcher with the launcher-isms cut out. It should be unindented a level, but I'm lazy and it's after midnight.

Code: Select all

    init python:
        import sys, os, subprocess 

        def launch(path):

            # Find the python executable to run.
            executable_path = os.path.dirname(sys.executable)

            if renpy.renpy.windows:
                extension = ".exe"
            else:
                extension = ""

            if persistent.windows_console:
                executables = [ "python" + extension ]
            else:
                executables = [ "pythonw" + extension ]

            executables.append(sys.executable)

            for i in executables:
                executable = os.path.join(executable_path, i)
                if os.path.exists(executable):
                    break
            else:
                raise Exception("Python interpreter not found: %r", executables)

            # Put together the basic command line.
            cmd = [ executable, "-EO", sys.argv[0], path ]

            # Launch the project.
            cmd = [ renpy.fsencode(i) for i in cmd ]

            subprocess.Popen(cmd)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: piinkpuddiin