Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running renpy through the editor #115

Closed
duckdoom4 opened this issue May 18, 2022 · 13 comments
Closed

Running renpy through the editor #115

duckdoom4 opened this issue May 18, 2022 · 13 comments
Labels
backlog Something that is not a priority and will be addressed in a future release discussion new feature

Comments

@duckdoom4
Copy link
Collaborator

duckdoom4 commented May 18, 2022

Edit: As stated in the comments below, it isn't quite supported. I'd like to look into the possibility of running renpy directly from VS Code.
Maybe with some help from the Ren'Py team we could even get debugging to work directly from VSCode.

This would require some back and forth with the Ren'Py team, as I'm not sure if this is something they agree with. This might cause issues because it would require going around the launcher.

So I saw some code that allows renpy to execute directly.
How does this work/ what is is for exactly? Might be nice to document it somewhere.

afbeelding

@duckdoom4 duckdoom4 added question Further information is requested discussion labels May 18, 2022
@LuqueDaniel
Copy link
Member

The intention was to use Ren'Py to generate the file "game/saves/navigation.json", which is used to identify the symbols.

Ping @rdurfee

@duckdoom4
Copy link
Collaborator Author

Ah I see. Might be nice to document how to run that so the file can be updated when needed?

@rdurfee
Copy link
Collaborator

rdurfee commented May 19, 2022

That file is updated whenever you launch your game or do a force compile in the launcher.

@duckdoom4 duckdoom4 added new feature and removed question Further information is requested labels Jul 8, 2022
@duckdoom4
Copy link
Collaborator Author

Gonna add @renpytom to the discussion to hear his thoughts on this

@renpytom
Copy link
Member

renpytom commented Jul 8, 2022

I have no problems with this, and I'd be interested in potentially allowing debugging and other features.

@duckdoom4 duckdoom4 added the backlog Something that is not a priority and will be addressed in a future release label Jan 29, 2023
@Selenyhr
Copy link

Selenyhr commented Feb 20, 2023

I have done some tests on the way Ren'Py behaves when trying to call the internal renpy.arguments.register_command commands. This way of proceeding is not part of Ren'Py public API. As far as I know the only Ren'Py argument command that is sort-of documented if the run command, thanks to the --warp argument: https://renpy.org/doc/html/developer_tools.html#warping-to-a-line

When trying to call onto Ren'Py from a shell to execute some of the actions the launcher does (like building, linting, etc.), I have found that:

  • on Windows, calling renpy.exe only works for commands that will not result in anything written in the shell window. This is most likely due to renpy.exe calling the pythonw executable, but I'm not sure about this. The lack of output may be something to be wary of. For example it renders lint useless because it writes to stdout unless adding a filename output
  • on Linux, calling renpy.sh works properly, and you will get shell output from it
  • on both platforms, calling lib/<platform>/python renpy.py works properly, and you can get the shell output to know how the command ran
  • I haven't tried it out on Mac because I don't own one, but it should behave pretty similar to Linux

As for the available commands (in Ren'Py 8.0.3, I have included the description from within the Ren'Py code):

renpy <project> run [--profile-display] [--debug-image-cache] [--warp filename:linenumber]

Runs the current project normally. Is the default command if nothing is specified.
--profile-display: If present, Ren'Py will report the amount of time it takes to draw the screen.
--debug-image-cache: If present, Ren'Py will log information regarding the contents of the image cache.
--warp: This takes as an argument a filename:linenumber pair, and tries to warp to the statement before that line number.

renpy <project> lint [filename] [--error_code]

Checks the script for errors and prints script statistics.
filename: The file to write to.
--error-code: If given, the error code is 0 if the game has no lint errros, 1 if lint errors are found.

renpy <project> compile

Recompiles the game script.

renpy <project> rmpersistent

Deletes the persistent data.

renpy <project> quit

Recompiles the game script.

renpy <project> add_from

Adds from clauses to call statements that are missing them.

renpy android_build <android_project> [--bundle] [--install] [--launch] [--destination destination]

Runs an Android build command
android_project: The path to the project directory.
--bundle: Builds an android app bundle.
--install: Installs the app on a device.
--launch: Launches the app after build and install complete. Implies --install.
--destination, --dest: The directory where the packaged files should be placed.

renpy distribute [--destination destination] [--packagedest packagedest] [--no-update] [--package package] [--no-archive] [--macapp macapp] [--format format] <project>

Runs a build command
--destination, --dest: The directory where the packaged files should be placed.
--packagedest: If given, gives the full path to the package file, without extensions.
--no-update: Prevents updates from being built.
--package: If given, a package to build. Defaults to building all packages.
--no-archive: If given, files will not be added to archives.
--macapp: If given, the path to a signed and notarized mac app.
--format: The format of package to build.
project: The path to the project directory.

renpy update_old_game <project>

Back-ups all rpyc files into old-game directory.
project: The path to the project directory.

renpy ios_create <project> <destination>

Creates an ios package I suppose? I've never used it since I don't own Apple hardware :) I've noticed it calls ios_populate right after, so this seems like the more complete of the two ios commands
project: The path to the Ren'Py project.
destination: The path the iOS project that will be created.

renpy ios_populate <project> <destination>

This actually builds the package.
project: The path to the Ren'Py project.
destination: The path the iOS project that will be created.

renpy set_projects_directory <projects>

Sets the projects directory for the launcher to find games in
projects: The path to the projects directory.

renpy get_projects_directory

Prints the currently used projects directory

renpy <project> generate_gui <target> [--width 1280] [--height 720] [--accent "#00b8c3"] [--boring "#000000"] [--light] [--template gui] [--language None] [--start] [--replace-images] [--replace-code] [--update-code]

Regenerates the default Ren'Py gui based on the passed parameters
target: The game into which the generated gui should be placed.
--width: The width of the generated gui. (default 1280)
--height: The height of the generated gui. (default 720)
--accent: The accent color used throughout the gui. (default #00b8c3)
--boring: The boring color used for the gui background. (default #000000)
--light: True if this is considered a light theme.
--template: The template directory containing source code. (default gui)
--language: The language to translate strings and comments to. (default None, which goes to english)
--start: Starts a new project, replacing images and code.
--replace-images: True if existing images should be overwritten.
--replace-code: True if an existing gui.rpy file should be overwritten.
--update-code: True if an existing gui.rpy file should be update.

renpy <project> director

Not sure what it does. Must be some old code.

renpy <project> gui_images

Refreshes the gui default images based on the gui colors

renpy <project> update <url> [--base base] [--force] [--key keyfile] [--simulate available|not_available|error]

Updates the project using specified URL
url: URL to fetch updates from
--base: The base directory of the game to update. Defaults to the current game.
--force: Force the update to run even if the version numbers are the same.
--key: A file giving the public key to use of the update.
--simulate: The simulation mode to use. One of available, not_available, or error.

renpy <project> dialogue <language> [--text] [--strings] [--notags] [--escape]

Extracts dialogue from the game into dialogue.tab or dialogue.txt
language: The language to extract dialogue for.
--text: Output the dialogue as plain text, instead of a tab-delimited file.
--strings: Output all translatable strings, not just dialogue.
--notags: Strip text tags from the dialogue.
--escape: Escape quotes and other special characters.

renpy <project> extract_strings <language> <destination> [--merge] [--force]

Extracts translated strings.
language: The language to extract translated strings from.
destination: The json file to store the translated strings into.
--merge: If given, the current contents of the file are preserved, and new contents are merged into the file.
--force: If given, noting happens if the language does not exist.

renpy <project> merge_strings <language> <source> [--reverse] [--replace]

Merges translated strings with the game script.
language: The language to merge translated strings to.
source: The json file to take translated strings from.
--reverse: Reverses the languages in the json file.
--replace: Replaces non-trivial translations.

renpy <project> translate <language> [--rot13] [--piglatin] [--empty] [--count] [--min-priority 0] [--max-priority 0] [--strings-only] [--common-only] [--no-todo]

Generates or updates translations.
language: The language to generate translations for.
--rot13: Apply rot13 while generating translations.
--piglatin: Apply pig latin while generating translations.
--empty: Produce empty strings while generating translations.
--count: Instead of generating files, print a count of missing translations.
--min-priority: Translate strings with more than this priority. (default 0)
--max-priority: Translate strings with less than this priority. (default 0)
--strings-only: Only translate strings (not dialogue).
--common-only: Only translate string from the common code.
--no-todo: Do not include the TODO flag.

Whew, that's a lot of info, but that's pretty much what I gathered up when analyzing how Ren'Py works when called from a CLI :)
Some commands are pretty underwhelming, but some of them may be quite interesting to include into the extension. For example lint, run, rmpersistent and compile (or quit, since they do the same thing) because they're the ones that work the exact same regardless of the project that is being developed. It doesn't depend on what languages are used within the game, or what kinds of distributions the developer wants to support :)

@duckdoom4
Copy link
Collaborator Author

That's some really great info you've gathered there. That will be very useful! Thanks a lot :)

This is something we've put on the backlog for now, but if you're interested feel free to make a pull request

@midgethetree
Copy link
Contributor

I see there's already been a PR related to this this, but it appears to require a separate extension to work (at the very least, I get a message that "debug type cmd is not supported" and a button to look for extensions that will support it). The command also doesn't seem to be runnable via Run And Debug despite discussion of that, and also depends on a configuration variable it doesn't actually let the user set. Is this an accurate impression of the state this feature is currently in?

I've whipped up some DebugAdapter and TaskProvider implementations that could allow for running, linting, etc. from within VSCode (with the flexibility to define new tasks with different commands/arguments), but I don't want to step on any toes if work's already being done to address the aforementioned issues with the existing run renpy command.

@duckdoom4
Copy link
Collaborator Author

@midgethetree The MR from a couple weeks ago was supposed to add support for that. Though reading your comment it seems that doesn't work as intended. Currently no one is working on this feature, so feel free to make a contribution to the project. Any help is very appreciated :)

@hsandt
Copy link

hsandt commented Oct 31, 2023

(already posted the first part on the PR itself but figured more people may see it in this open issue)

I have a different error when running the command Run: Renpy: Run Project added by #291 :

Ren'Py executable location not configured or is invalid.

Unfortunately, for some reason the setting config.renpyExecutableLocation is not visible in Settings > Extensions > Ren'Py (there are only 10 settings, from editor.defaultFoldingRangeProvider to renpy.watchFoldersForChanges). If this was fixed though (by adding the setting I suppose), then maybe we could fix this issue thanks to this command.

(below is new content)

For now, I use the following:

  • install plugin F5 Anything (yeah, didn't find a way to run shell out-of-the-box either for Launch commands; you can do it with tasks if you don't mind hacking around by running a dummy launch with a preLaunchTask)
  • in launch.json, add:
{
    "name": "Renpy: play game (Linux/macOS)",
    "type": "f5anything",
    "request": "launch",
    "command": "renpy.sh project_folder",
}

and do the same with .exe for Windows (untested)

@duckdoom4
Copy link
Collaborator Author

Thanks for taking the time to add a workaround solution. Very much appreciated! 🚀

@midgethetree
Copy link
Contributor

Renpy: Renpy Executable Location shows up in the extension settings for me and I can run Ren'Py with F5, but that's only with the v2.3.6 prerelease that includes my PR (#360). I believe I fixed "Run: Renpy: Run Project" in that PR too, although I personally just use F5 rather than launch Ren'Py through the command palette.

@hsandt
Copy link

hsandt commented Nov 15, 2023

Thanks, it works with the pre-release v2.3.6!

  • Extensions > Ren'Py Language > Switch to Pre-Release Version

image

  • Settings > Renpy > Renpy Executable Location

image

I have a last unrelated issue that prevents me from running the project: spaces in project path are not supported... Will open an issue soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Something that is not a priority and will be addressed in a future release discussion new feature
Projects
None yet
Development

No branches or pull requests

7 participants