Repository navigation
Export a scene to Ren'Py and serve its web build at /renpy - #401
Merged
Merged
Conversation
Renpy::Export writes a story's opening, or a playthrough's scene_chain,
as a Ren'Py project: one Ren'Py scene per Scene row, every line narration
from scenes.description one sentence per click, the cast standing where
Renpy::Placement puts them (the person spoken to centred), the protagonist
as the narrator's side image, and Ren'Py's own placeholders for every
picture. Image names come from record ids; [, {, " and \ are escaped.
rake renpy:export / renpy:build run Ren'Py 8.6.2's SDK (TA_RENPY_SDK,
outside the repository): generate_gui, gui_images, lint --error-code and
launcher web_build, into TA_RENPY_ROOT. The app mounts that folder at
/renpy (browser install only), sends .wasm as application/wasm, and lists
the builds at /renpy/ with Ren'Py's licence link. AGENTS.md names the
Ren'Py build tool as the second exception to the zero-build-step rule.
No model calls; no text a model reads changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stage 1 of the Ren'Py proof scene: export a scene to Ren'Py and serve its web build from this server. No pictures, no model calls, no spend, and no text a model reads changes.
What it does
Renpy::Export(app/models/renpy/export.rb) writes a story's opening, or a playthrough'sscene_chain, as a Ren'Py project (game/script.rpy).sceneperScenerow.scenes.description, one sentence per click. Speech is not split out of the prose.bg l<id>,c<id> neutral,side c<id>).Renpy::Placementdecides who stands where. The cast is the scene'scharacters_scenesminus the protagonist, plus the person talked to on atalkturn.Renpy::Texthandles escaping and sentence splitting:[becomes[[,{becomes{{, and"and\are backslashed..,!,?or…followed by a capital. No word is ever dropped.rake renpy:export[story]andrake renpy:build[story], orPLAYTHROUGH=<id or token>for one game's turns.Renpy::Buildruns the SDK steps:launcher generate_guiat 1920×1080, once per project. Without it there is no side image and only a bare text box.gui_images, normal and phone. Without these the build stops at the main menu with "could not find image".lint --error-code.launcher web_buildinto a staging folder, which is then moved intoTA_RENPY_ROOT/<name>-<script digest>/./renpymount (Renpy::Files,config/routes.rb):Rack::FilesoverTA_RENPY_ROOT(defaultstorage/renpy), drawn below the hosted-mode cut, so the browser install has it and a hosted instance does not..wasmis sent asapplication/wasmand every file ascache-control: no-cache.index.html, and a folder requested without its trailing slash redirects to it./renpy/lists the builds with Ren'Py's licence link, in the wording Ren'Py's licence page suggests (Renpy::Index).TA_RENPY_SDKandTA_RENPY_ROOT(config/application.rb,deploy/local/deploy.env.example).docs/local-deploy.md, plus a short README section.The Ren'Py SDK: how it is obtained and where it lives
It is never committed, and the app runs and serves without it; only
rake renpy:buildneeds it.To prove the build, I downloaded Ren'Py 8.6.2 from renpy.org to
~/.cache/renpy-sdk/on the build machine, outside the repository:renpy-8.6.2-sdk.tar.bz2andrenpy-8.6.2-web.zip;https://www.renpy.org/dl/8.6.2/checksums.txt;web/sits besiderenpy.sh, because the launcher cannot install web support without a window.docs/local-deploy.mdgives the same steps for the private install, under~/.local/share/text-adventure-web/renpy-8.6.2-sdk.Proven on this machine
bin/rails 'renpy:build[The Lunar Cartographer]'on a freshly seeded database ran every step headless, with no xvfb, in about 11 seconds. The build is about 46 MB.bin/rails serverand played it in Chrome at/renpy/story-1-<digest>/. It showed:[,{and"shown as written.web_buildneeds noset_projectfirst;generate_guiandgui_images.Tests
test/models/renpy/export_test.rb:test/fixtures/files/renpy/the-lunar-cartographer-opening.rpy);placement_test.rbandtext_test.rbcover who stands where, and sentence splitting with escaping.test/integration/renpy_files_test.rbserves a small fixture build:renpy.wasmasapplication/wasm, the trailing-slash redirects, a path outside the folder refused, and an empty root returning 404.renpy.sh lint --error-coderuns on two exports (the seeded opening and an escaping case) whenTA_RENPY_SDKis set, and is skipped otherwise. With the SDK set it passes. Lint catches a parse error or an undefined image. It does not read say text, so an unescaped[,{or"passes it; I checked this. The escaping test is the guard there.build_test.rbandindex_test.rbcover the error messages when the SDK is missing or wrong, and the list page.Checks
All run with
OPENROUTER_API_KEY,TYPESAFE_API_KEYandTA_RENPY_SDKunset:bin/rails test: 5537 runs, 0 failures, 0 errors, 1 skip (the SDK lint test);bundle exec rubocop: no offences;bin/rails zeitwerk:check: all good;bin/brakeman --no-pager: no warnings.No migration, and no
Update::REGISTRYstep is needed.