Ren'Py How to Create a Mod Cheat in RenPy

REx344

New Member
Feb 2, 2024
14
11
As the title suggests, I want to know how to create a cheat in Ren'Py to add money or increase relationships. Could Anyone provide a tutorial or guide?
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,591
2,238
I'm going to assume you mean you want to cheat at a game...

The simple answer is that you need to be able to access the RenPy Developer Console.

It's disabled by default, but you can switch it on a number of ways.
The simplest is to grab UnRen, unpack it into the game folder, run it and then select option "3" (Enable Console and Developer Menu).
This will create a file in your game folder that will switch the console on for you.

While running the game, press <SHIFT>+O. (the letter O).

This will open the console and you can enter RenPy and python commands to do stuff... like changing the amount of money you have and other values.

Of course... nothing is ever that simple.

You need to know the name of the variables. I mean money = 10000 is a pretty safe bet in most games that use money. But maybe it's called something else.
For that, you need to be able to read and understand the game's script files.

RenPy runs .rpyc files (think "renpy compiled code"). Sometimes those files are stored in .rpa archives.
But the original source code is stored as .rpy files.

If you can't see .rpy files in the /game/ folder, then you'll either need to unpack the .rpa files or decompile the .rpyc files back into .rpy files (OR BOTH).

Again, this is where UnRen comes in. It will both unpack .rpa files and decompile .rpyc back into .rpy files.

Unpack the files if needed. Decompile the files if needed. Then take a look a the .rpy files that make up the game by loading them in a text editor (DON'T change them. DON'T save them).

Obviously, there are lots of commands you can enter at the console, but the top 3 are probably:
  • print <variable>
  • <variable> = <newvalue>
  • watch <variable>

There's also unwatch <variable> I suppose.

For example, one game I've just started doesn't use money, but has a points system. Two characters are called Gloria and Elsa. These are commands and responses I got at the console:

Code:
Press <Esc> to exit console. Type help for help.
Ren'Py script enabled.

print money
NameError: name 'money' is not defined
Traceback (most recent call last):
  File "renpy/common/00console.rpy", line 689, in run
    renpy.python.py_exec(code)
  File "renpy/python.py", line 2258, in py_exec
    exec(py_compile(source, 'exec'), store, locals)
  File "<none>", line 1 in <module>
NameError: name 'money is not defined

print gloria_points
10

print elsa_points
3

elsa_points = 30
print elsa_points
30

watch gloria_points
watch elsa_points

> _

I knew the variables were called gloria_points and elsa_points because I'd already looked at the source code.

Problem is, that's pretty much all I can suggest from a console point of view. If you don't understand how to read the source code or you don't understand the commands - you're stuck.

If you want to create a "mod" for a game, which allows any player to cheat - that's a whole different ball game.
 
  • Like
Reactions: REx344

REx344

New Member
Feb 2, 2024
14
11
I'm going to assume you mean you want to cheat at a game...

The simple answer is that you need to be able to access the RenPy Developer Console.

It's disabled by default, but you can switch it on a number of ways.
The simplest is to grab UnRen, unpack it into the game folder, run it and then select option "3" (Enable Console and Developer Menu).
This will create a file in your game folder that will switch the console on for you.

While running the game, press <SHIFT>+O. (the letter O).

This will open the console and you can enter RenPy and python commands to do stuff... like changing the amount of money you have and other values.

Of course... nothing is ever that simple.

You need to know the name of the variables. I mean money = 10000 is a pretty safe bet in most games that use money. But maybe it's called something else.
For that, you need to be able to read and understand the game's script files.

RenPy runs .rpyc files (think "renpy compiled code"). Sometimes those files are stored in .rpa archives.
But the original source code is stored as .rpy files.

If you can't see .rpy files in the /game/ folder, then you'll either need to unpack the .rpa files or decompile the .rpyc files back into .rpy files (OR BOTH).

Again, this is where UnRen comes in. It will both unpack .rpa files and decompile .rpyc back into .rpy files.

Unpack the files if needed. Decompile the files if needed. Then take a look a the .rpy files that make up the game by loading them in a text editor (DON'T change them. DON'T save them).

Obviously, there are lots of commands you can enter at the console, but the top 3 are probably:
  • print <variable>
  • <variable> = <newvalue>
  • watch <variable>

There's also unwatch <variable> I suppose.

For example, one game I've just started doesn't use money, but has a points system. Two characters are called Gloria and Elsa. These are commands and responses I got at the console:

Code:
Press <Esc> to exit console. Type help for help.
Ren'Py script enabled.

print money
NameError: name 'money' is not defined
Traceback (most recent call last):
  File "renpy/common/00console.rpy", line 689, in run
    renpy.python.py_exec(code)
  File "renpy/python.py", line 2258, in py_exec
    exec(py_compile(source, 'exec'), store, locals)
  File "<none>", line 1 in <module>
NameError: name 'money is not defined

print gloria_points
10

print elsa_points
3

elsa_points = 30
print elsa_points
30

watch gloria_points
watch elsa_points

> _

I knew the variables were called gloria_points and elsa_points because I'd already looked at the source code.

Problem is, that's pretty much all I can suggest from a console point of view. If you don't understand how to read the source code or you don't understand the commands - you're stuck.

If you want to create a "mod" for a game, which allows any player to cheat - that's a whole different ball game.
Sorry for not mentioning that I want to know about mod ,Yes i want to learn how to create a cheat mod for the game Any Help?
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,591
2,238
Sorry for not mentioning that I want to know about mod

Don't worry about it. You did sort of mention it in the title of the thread. But it was vague, so I figured I'd focus on the easy answer rather than the harder one.

Do you have a specific game in mind?
Or are you looking for the general knowledge about how to create a cheat mod?
Have you done any RenPy coding?


That final one is probably going to determine how complex the answer might be.
My first thought is that it's probably going to take some (non-basic) understanding of a subset of RenPy's scripting called .
 
Last edited:
  • Red Heart
Reactions: REx344

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,561
15,520
Yes i want to learn how to create a cheat mod for the game Any Help?
Well, what 79flavors said still partly apply.

To create a cheat mod you need three things:
  1. To know what variables are used.
    For this, you can use the embedded variable viewer (CTRL + D with the developer mode enabled), searching a variable with the right value. Or you can use my extended variable viewer (link in my signature), that is easier to use and more complete.

  2. To know what are the values for those variables.
    Knowing what are the variable names will never be enough. You also need to know how the game will deal with them. If it's a list, by example, you'll need to ensure that you'll not overflow. If it's a integer, like usually used for money or health, you need to know if there's a limit, because it would be ridiculous to increase it further than needed.
    But more important, you need to know how the game react to those value changes. Having a stats reach a given value will perhaps trigger an event, and if you create your mod blindly, it will not be triggered when you cheat.
    For this, there's no secret, you need to browse the whole code of the game, from end to starts.

  3. To know how to add your mod in top of the game.
    For just a cheat mod, it's something relatively easy to do, because it only need one screen, two at most (one opening the cheat menu, and one that will be the cheat menu).
    For this, you have to define your screen, then use the configuration list, in an init block, to have your screen always visible.

The rest is just knowing how to read/write code.
 
  • Red Heart
Reactions: REx344

REx344

New Member
Feb 2, 2024
14
11
Don't worry about it. You did sort of mention it in the title of the thread. But it was vague, so I figured I'd focus on the easy answer rather than the harder one.

Do you have a specific game in mind?
Or are you looking for the general knowledge about how to create a cheat mod?
Have you done any RenPy coding?


That final one is probably going to determine how complex the answer might be.
My first thought is that it's probably going to take some (non-basic) understanding of a subset of RenPy's scripting called .
1. Yesterday's Crossroads
2.Yes from basic mean how to connect your cheat rpy to screen rpy and other
3.i think no just some basic Highlighting the Best Choices .
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,591
2,238

Before going any further, I'll point out that Yesterday's Crossroads already has a cheat mod. A very, very well written one.
(at least as far as I can see, during the 3 minutes or so I've played with it).

In the download section of the original post...

1723480140478.png

After you've unpacked it into the game folder and run the game, you'll see it there.

If you then go into its options screen, top right corner is a "Cheats" menu.

1723480242573.png


1723480573115.png

I'm unsure if the mod is up to date with the current version of the game.

Cheats don't seem to be the main function of the mod, but they are there.

I would normally suggest that you could UnRen it to see how it's written... but it's severely over-engineered for a beginner.
It does however demonstrate what Anne was talking about... A small screen which is always there in the bottom right hand corner, which when clicked opens up other screens which do other stuff.

Now you know it exists for the game you are interested in... is this still something you want to write yourself? Or are you happy to use the existing one?
 
Last edited:
  • Like
Reactions: REx344

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,561
15,520
I'm unsure if the mod is up to date with the current version of the game.
Sancho1969 being missing since six weeks, in concerning circumstances, so it probably isn't up to date, or soon will not be.
But it's still an opportunity to take a look at both the mod and the game, to see what are the variables, how they are used in the game and in the mod.
 

REx344

New Member
Feb 2, 2024
14
11
Before going any further, I'll point out that Yesterday's Crossroads already has a cheat mod. A very, very well written one.
(at least as far as I can see, during the 3 minutes or so I've played with it).

In the download section of the original post...

View attachment 3924535

After you've unpacked it into the game folder and run the game, you'll see it there.

If you then go into its options screen, top right corner is a "Cheats" menu.

View attachment 3924540


View attachment 3924575

I'm unsure if the mod is up to date with the current version of the game.

Cheats don't seem to be the main function of the mod, but they are there.

I would normally suggest that you could UnRen it to see how it's written... but it's severely over-engineered for a beginner.
It does however demonstrate what Anne was talking about... A small screen which is always there in the bottom right hand corner, which when clicked opens up other screens which do other stuff.

Now you know it exists for the game you are interested in... is this still something you want to write yourself? Or are you happy to use the existing one?
I tried making same,but the value for other is starting from five. have taken help of other mod and just changes value.Any Help on how to make them 0?
Capture.PNG
 
Last edited:

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,591
2,238
I tried making same,but the value for other is starting from five. have taken help of other mod and just changes value.Any Help on how to make them 0?

Very quick reply with very little thought:

Python:
            text "Candace Affection"
            fixed:
                xysize(400,50)
                bar value VariableValue("candace_affection", 200)
                text "[candace_affection]" xcenter 0.5 ycenter 0.45

The current value of candace_affection is 5, so that's what it's showing. Then because you are setting the maximum value as "200", that 5 looks like it's all the way to the left.
Edit: Actually, in your example Candace is 0, not 5. That's just the bit of code I cut and paste. Told you I was replying with very little thought. o_O

The current value is 5 because that's what the game picked for the starting value for that character. Some characters start at 5, some at 0 - from what little I saw when I played the game for a few minutes.

I suspect that if you drag the slider to the left, it will go down to zero.

I don't know the game, but the other mod seemed to set the maximum to 10 rather than 200. Perhaps try that... at the very least, it will mean a value of 5 will show in the middle, rather than the far left.

Or put another way. 5 out of 200 is tiny. 5 out of 10 is half.

For more info, refer to the manual:
 
Last edited:

REx344

New Member
Feb 2, 2024
14
11
Very quick reply with very little thought:

Python:
            text "Candace Affection"
            fixed:
                xysize(400,50)
                bar value VariableValue("candace_affection", 200)
                text "[candace_affection]" xcenter 0.5 ycenter 0.45

The current values of candace_affection is 5, so that's what it's showing. Then because you are setting the maximum value as "200", that 5 looks like it's all the way to the left.

The current value is 5 because that's what the game picked for the starting value for that character. Some characters start at 5, some at 0 - from what little I saw when I played the game for a few minutes.

I suspect that if you drag the slider to the left, it will go down to zero.

I don't know the game, but the other mod seemed to set the maximum to 10 rather than 200. Perhaps try that... at the very least, it will mean a value of 5 will show in the middle, rather than the far left.

Or put another way. 5 out of 200 is tiny. 5 out of 10 is half.

For more info, refer to the manual:
Ok Thank You:)