Tutorial Ren'Py Hacking Ren'Py Games, What To Do When You Are Stuck

thesappho

Newbie
Jun 24, 2017
45
74
This post is about; how to unlock scenes and when you are stuck how to progress in a renpy game. I think this post will help everybody stuck in any/most renpy games.

So, you are stuck how would it be possible to progress?

A renpy game basically is, as you may well know, a stuctured text (python) showing images(jpeg, pngs, etc. and some videos-webms and such) when conditions are met/right in its statements.

When you search filename of the image in a scene in renpy files you will see conditions how to access to scene with file modification or change game values. I will show the route with changing values in the game through the console. Other route may (and very possibly will) break your game installation (or archive extraction :)). Now i will list the steps to successfully alter game:

1) Enable in game console.
2) Extract images and game code (read the warning in that section for duplicate files!!)
3) Find desired scenes
4) Install a file search tool (Notepad++ in my case).
5) (optional)Change in game values. voila!

1) How to enable in game console?
We have to modify "00console.rpy" file in this folder "GAMENAME\renpy\common\".

01-Console01.png

Open this file with noterpad++ or a standart text editor and find "config.console = False". It is generally near 100th line.Change this to "config.console = True", just edit the word "False" to "True". Indentation and spelling is important in python, if you change the identation or write "true" there will be errors.

01-Console02-False.png

01-Console01-True.png
Save the file and quit the text editor.

2) Now the most tricky part of this tutorial. Some renpy games contain media (pictures, audio and movies) and game code in archives (.rpa files). Some games contain only media as archive but game code as extracted. And some cases game codes are encrypted as .rpyc files. If there are .rpy files then they are not encrypted(generally unencrypted files reside next to encrypted files, eg: "gamecode.rpy" and "gamecode.rpyc"). If media and game codes (as well as unencrypted) are not in a archive you may skip this step. But very possibly either they are in a archive and game codes are encrypted. (Also you can use this awesome tool by Sam: )

You can archives and game codes in "GAMENAME\game\" folder:
02-CheckGameFiles.png
So, "Second_happiness-1.0-all" contains media in an archive and game codes are encrypted :(

So if either files are in an archive or game codes are encrypted then follow thsese steps:

a) install python

Get python from:


You may install python for a number of platforms; windows, linux, mac etc.
After installation lets check if it works:
02-PythonVersion.png
If python is installed properly you may execute python from any directory in console. You see we checked python version inside "game" directory of our renpy game. If there is an error you may need to restart your operating system for environmental values to apply. If you have an error visit:


Now I assume everything is OK with your python installation.

Now we need two tools to extract archives and decode game codes:



download these and copy inside the "game" folder.

02-rpatoolANDunrpyc.png


You may have trouble with downloading from github if you have no experience using github :). If i won't forget, i will upload them in this post.

So let's start with extracting the .rpa archive(s). All commands are to executed without quotation marks!!! I put them to mark them.
Before invoking command, this is how the "game" folder seems:

02-Extract-01-FolderBefore.png

So we will invoke this command in console:
"python rpatool.py -x archive.rpa"
02-Extract-01-Console.png

and also we have two archives, lets extract archiveF10.rpa too:
"python rpatool.py -x archiveF10.rpa.rpa"
02-Extract-02-ConsoleAfter.png

Now the folder seems like this:

02-Extract-02-FolderAfter.png

Now you see a lot of files added!. Now one of the most important thing to do:
DELETE ARCHIVE FILES, OR MOVE THEM TO ANOTHER FOLDER OUTSIDE GAME FOLDER OR CHANGE THEIR EXTENSION (.rpa to .rpaxx for example). I change their extension:

02-Extract-03-ChangeArchiveExt.png

Because now we launch the game renpy tries to process extracted media files and game codes twice and will throw an error!!!! You have been warned.

Now lets decode/decompile .rpyc file. Extract "unrpyc.zip" (or "unrpyc-master.zip") to your game directory (extract files inside "unrpyc-master" directory inside zip file to "game" folder):

02-unrpycFiles.png

Now lets decompile them from console with the command:
"python unrpyc.py -c *.rpyc"

02-unpycCommand.png


Now if you see this:

02-unpycCommandAfter.png

02-unrpycFilesAfter.png

VOILA!!!!!

Most of the hard work is finished :)))

3) Now, this step will tell you how to find missing scenes/or how to progress when you are stuck. In this bit I will try to explain in detail about game mechanics(as renpy it it very basic):

I previously stated the obvious: A renpy game is actually bunch of media files (pictures, videos and audio) put sequentially when some conditions are met. I will put an example of renpy code block first a more human readable code (renpy/python code is obviously may be considered as clear human readable, you may say mine as "non programmer human readable :)").
**************
(a scene starts)
show image image1
show image image2
change visit_number by adding 1 to it
if user visited this scene 3 or more times show below images
show image image3
show image image3
show a multiple choice to user
choice1
choice2
if user clicks choice1, increase money with 200
if user clicks choice2, go to other scene
(scene ends)
**************

now lets put this in renpy words, a scene (group of images or a group of codes to execute) is generally marked as "label" in renpy. An image is displayed with "scene". Of course there are more details in these but this is the basic usage:

**************
label beach:
scene BeachShantSea1
scene BeachShantSea2
if(shant_money_beach >=3):
scene BeachShantSea3
scene BeachShantSea4
menu:
"Give money":
$ shant_money += 200
"pass":
jump beach_money1

**************

So what happens in the code block?
There is a scene (or a set of images and statements to be executed) defined as "beach". It sequentially displays BeachShantSea1 and BeachShantSea2 images. If shant_money_beach is 3 or more; display BeachShantSea3 and BeachShantSea4 images and at the end, present user with two options. If user clicks "Give money" then increase the variable shant_money by 200 (if you have given shantrel 2150$ by now, after this shantrel would have 2350$, thus "shant_money" would be 2350). if user clicks "pass" you would jump to another set of images called as "beach_money". The important point in this block is that if "shant_money_beach" is less than 3 then you won't get to the part of BeachShantSea3 and BeachShantSea4 images. So somewhere in code there must be a "$ shant_money_beach +=1". That would be inside (probably) in other scene (or as in renpy terms "label").

This may seem frustrating at first, but if you follow just a little more and after some real practice you will get expert providing yourself with basic solutions.

Now it is important to learn how renpy processes images under "game" director or under sub-directories of "game" folder. Renpy flattens sub-directories and extensions of image files. What?
Let's have an example. After extraction browse sub-directories of "game" folder. Lets look under "CharShantel" and "CharBrenda" directories

03-ImageFilesEx01.png

03-ImageFilesEx02.png
how does an image called from a renpy statement? (there are actually different implementations, but generally Second Happiness and other use basic notation). Let's take the image "BeachShantSea11.jpg" from "\game\CharShantrel". So when you call this image with "scene" keyword in renpy, you would type:

"scene BeachShantSea11"

What? Why not "scene \game\CharShantrel\BeachShantSea11.jpg" or "scene \CharShantrel\BeachShantSea11.jpg" or etc? renpy flattens all relevant file location and file extension!!. So the image below:

\game\{sub-directory1}\{imagefilename1}.{imageextension/type}

becomes just:

imagefilename1

This part is important. All relevant file location and image extension is thrown out. Of course in some neatly and better designed renpy games you may have:

image shantrel beach image one = "\CharShantrel\BeachShantSea11.jpg"

so let's wrap it up:
* renpy flattens of file location and extension from files, so:

"\game\CharShantrel\BeachShantSea11.jpg" becomes "BeachShantSea11" , you may have sets of sub-directories, so again:

"\game\CharShantrel\BeachShantSea11.jpg" => BeachShantSea11
"\game\CharShantrel\folder2\BeachShantSea12.jpg" => BeachShantSea12
"\game\dir1\dir3\dir5\image1.png" => image1

There won't be a problem sequential files having DIFFERENT extensions:

"game\dir1\image1.png"
"game\dir1\image2.jpg"
"game\dir1\image3.jpg"
"game\dir1\image4.png"

but you can't have same names even in different directories:

"game\dir1\image1.png"
"game\dir1\image2.jpg"
"game\dir1\image3.jpg"
"game\dir5\image1.jpg"

there will be a call of two "image1" image even with different extensions and in different directories. If you use good notation stated above, actually you may. But not with simple "scene" keyword, if you write following in a renpy code:

scene image1

you will have a bad time.

Most of this information concerns a renpy game programmer. I have given this information just to give you better understating of following steps.

Now let's find a real world example that concerns us. For example the image "Sh06PornTV7.jpg" under "\game\CharShantrel\Sh06PornTV7.jpg" . This is an extended scene(image) displayed in TV watching event.

4) Install Notepad++ 8or any text processor with a capability of searching a keyword inside a bunch of files in any sub-diretory. Download notepad++ from:



Install it, then run the program:

04-npp.png

Press CTRL+Shift+F of Search-> Find in files

04-npp-01.png


Now fill in these:

Find what => Sh06PornTV7
Filters => *.rpy (if you dont set this notepad++ will search every file!!!)
Directory => full path of game directory for our game, now in my case:

04-npp-02.png

now press "Find All":

04-npp-03.png

and, voila:

04-npp-04.png

Now double click the result (the line says Line xxx) it will take us the the .rpy code with the relevant line:

04-npp-05.png

now you will see that there is an "if" block with conditions:

if (shant_tv_porn == 702 or shant_tv_porn == 703 or shant_tv_porn == 704 or shant_tv_porn == 705):

so if the variable "shant_tv_porn" is not 702, 703, 704 or 705 you won't advance to "Sh06PornTV7" scene(actually image). Now let's run the game and find the value stored as "shant_tv_porn" in our save.

By the way I had the following error:

04-npp-06.png

I deleted the sub-directory "testcases" under "game" directory, everything went fine. Now load our save and after loading our save press "SHIFT+O" to open console:

before SHIFT+O
05-renpyConsole-01.png

after SHIFT+O

05-renpyConsole-02.png

you may notice an command input at the uppermost section of the screen. To display our variable in question "shant_tv_porn" enter it:

05-renpyConsole-03.png


press enter then you see:

05-renpyConsole-04.png

so in my save in question my variable of "shant_tv_porn" is 700. You may press ESC to colse console!!!. Now if we enter:

shant_tv_porn = 702

in the console and press enter then we will set the variable "shant_tv_porn" to 702 in game and if we save the game this variable will be stored as 702 and next time we will be able to advance to the scene Sh06PornTV7 part. But this short cut would (and in most cases WILL break some parts of the game). So let's take not the easist route but the solid route: Find the codeblock where "shant_tv_porn" is altered in game code and how we would really and lawfully!!! advance in the game.

OK, how we would do this? By searching "shant_tv_porn" in notepad++ in rpy files :) :

05-nppfindvar-01.png

now this frigging confusing, isn't it?

05-nppfindvar-02.png

actually not after we talk about assignment and checking of variable in renpy (or most programming languages).

When a single equal sign "=" is used, it tells program to assign the number/value on the right of statement to the value in the left. So:

a = 500

means; take 500 and assign to variable "a" and now variable "a" is 500.

When a double equal sign "==" is used, it tells program to check if the value/variable in the right is EQUAL to the variable in the left, so:

a == 400

means; is "a" is equal to 500?

In programming languages (in most of them) the single equal sign "=" is an assignment of a value/variable to another, double equal sign "==" is to check a condition. You may check for further detail:


After you get the concept it is easier to process the find results. We will check the results with assignment operators; "=" or "+=". What? What the f.ck is "+="?

"+=" means increment the variable on the left with the value/variable on the right. So in results there are couple of points of interest:

* Line 236 $ shant_tv_porn += 1
(this states that there is a condition which increases shant_tv_porn with 1.

* Line 290 if (shant_tv_porn == 700):
Line 291 $ shant_tv_porn = 701

* Line 296 if (shant_tv_porn == 701):
Line 297 $ shant_tv_porn = 702

* Line 352 $ shant_tv_porn = 703

* Line 348 $ shant_tv_porn = 704

* Line 355 if (shant_tv_porn < 699):
Line 356 $ shant_tv_porn = 700

So if your "shant_tv_porn" is lower you should click the result with line 355. But in my real shant_tv_porn = 700 case (which we got from console in the game) I must first increase it 701 and then to 702 ( because to display "Sh06PornTV7" we found this code : "if (shant_tv_porn == 702 or shant_tv_porn == 703 or shant_tv_porn == 704 or shant_tv_porn == 705):" above)

So in order to progress without breaking game lets click line 290:

05-nppfindvar-03.png

now i speak english and the dialog language as default is russian in game codes we will make and additional search for russian text in our game progress to get out where where are stuck. So lets take this block from our results:

05-nppfindvar-04.png

this part show how we can increase our "shant_tv_porn" value from 700 to 702. We (I) should translate russian text from google translate:



Трогать = Touch
Ты вообще меня не слушаешься! = You do not listen to me at all!
(this choice makes our variable 701)


Нет = No
Я ушла, а ты мультики смотри! = I'm gone and you watch cartoons
(this choice makes our variable 702)

So we know this scene, saturday evening, we will turn on porn first, then we will turn it off. And when we get to this option:

05-SceneInGame.png

First time we will select "Touch", then next week/time we will select "No".

That is all!!!!!!! WE MADE IT. WE PROGRESSED TO DESIRED SCENE.

Extra info about our scene:::
************
Also if you have some programming experience, you may see that changing shant_tv_porn to 702 from console would not break the game if our initial value is 700, because both choices ("Touch" and "No") only changes our desired variable "shant_tv_porn" and jumps to same label "jump shant_hall_tv_end2". If there was a block like this:

"Трогать":

scene Sh06PornTV6 with Dissolve(0.5, alpha=True)
shantrelN "Ты вообще меня не слушаешься!"

"...{image=HeartQue.png}"

if (shant_tv_porn == 700):

$ shant_tv_porn = 701

$ shant_tv_variable = 5
jump shant_hall_tv_end2

I put an extra variable assigment "$ shant_tv_variable = 5" to this block. So if we would change "shant_tv_porn" from console, the other intended variable of "shant_tv_variable" would not be assigned 5 and your whole game would break!!!!!!!!!!!!

If I have time I will color this manual and create a pdf. But it may take time.


Now; to practice I may get two requests from you who are stuck. And want to progress to certain event/image/scene. find the appropriate image and and post referring me in your post. It is sunday and probably I will reply monday at best.

If you want to buy a beer to me, you may use this bitcoin adress :) :
3GhY43bNj8dtHmNKSGqNGYz8zhJE39CK7u

Thanks. Feel free to correct any mistakes.

Edit1: Images weren't displayed, corrected them
 

Magixian

Member
Feb 2, 2017
214
308
Great guide that sums up alot of what i struggled with starting to learn renpy/python. Would recommend an editor that can read renpy or python. Personally i use as you can choose coding language.

If you want of just reading the gamescripts, you can copy this into the ../game/ folder. Open the game once, and you get the .rpa into textfiles. Delete/move the decompile.rpy afterwards, so the game doesn't initiate each startup. This really saves you alot of time.
 

leproso0413

Well-Known Member
May 26, 2017
1,333
310
How do you translate a renpy game? I want to play SolValley translated into Spanish and the one that I think the game already gave me permission, but my idea is translated for me, how do you know?
 

TCMS

Quote my posts if you want an answer
Donor
Former Staff
Aug 5, 2016
5,797
29,927
I know this thread is quite old but here's an advice:
Instead of extracting or changing the console manually you can always use .
 

cscorp

Member
Dec 22, 2018
109
10
So I just received a notice while trying to save the game. I received an "exception has occurred" on my screen and I noticed a trackback.exe. thing. Don't know what that is or means but I don't have the option to go back, skip, etc. on the bottom. Any idea how I can fix this and get those options back?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
9,953
14,552
So I just received a notice while trying to save the game. I received an "exception has occurred" on my screen and I noticed a trackback.exe. thing. Don't know what that is or means but I don't have the option to go back, skip, etc. on the bottom. Any idea how I can fix this and get those options back?
Hmm. What have you done for that ?
This happen only where the data to save have been corrupted and the game try to save code in addition to pure data. And the only way to fix this is to find the culprit variable(s) and to reset them. But it's far to be something trivial ; it can break the whole game and not just the possibility to save it.

But as I implied, this is something really unlikely to happen. If you did absolutely nothing and it really come from the game, then there's really high chance that at least half the players had the same error, and the author will release a bugfix.