Save modification (renpy new variables)

Zack99

Newbie
Jan 14, 2018
17
7
Hi everyone, I’m having a problematic situation in renpy games, so people that has edited saves before probably has notice that in games besides the point increase/decrease system and the true or false for events, there are some cases in which choices actually add a new variable in the save, from new stats to new events to other parameters, now I assume that developers most likely don’t put all variables from the start to make the files lighter or prevent bugs and the like, but also as a trigger for future events, my problems comes here, let’s say that you have a choice 1/3 in game that haves 5 different outcomes, each outcome triggers the activation of 1 different variable, and said variable is used much later in game like 4/5 of in game progress to activate different events and the like. The question, Is there a way to actually activate all variables to modify them, add variables manually, merge saves or just use commands from the console to make this happened so I don’t have to restart all progress?
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,582
2,219
[...] now I assume that developers most likely don’t put all variables from the start to make the files lighter or prevent bugs and the like
Nope.

It's because they make this shit up as they go along. They add something that needs a variable, they add that variable there and then. Invariably they're also just copying how someone else did it in the past.
Also, if they are releasing their game in chapters/days/versions, then there's already a version of that game out in the wild that doesn't include the variable... so depending on their level of knowledge - they keep it simple by only creating variables when they need them.
There is of course a better way... which is to create variables using the default statement - which ignores where in the code the variable is created and instead creates all variables using default before the game starts.

[...] let’s say that you have a choice 1/3 in game that haves 5 different outcomes, each outcome triggers the activation of 1 different variable
This would be HIGHLY unlikely. There's a lot of crap code out there, so I'm not saying impossible - but still unlikely.

Games crash if they reference a variable that hasn't been created. So usually, even if a variable is exclusive to a particular path - even the most inept developers only reference that variable if the other variables/choices that led to that path are met.

Much more common is that the variable is created but never given a value that makes sense, dependent on player choices.

By which I mean, I think you may be worried about a combination of circumstances which are more theoretical than practical.

Is there a way to actually activate all variables to modify them, add variables manually, merge saves or just use commands from the console to make this happened so I don’t have to restart all progress?
The most common solution would be to enable the console and use console commands to add/modify variables

UnRen will do it for you if need be. (Make sure you use the 0.9 dev version, as recent improvements to RenPy mean that 0.8 doesn't always work).
Then open the console while the game is running. <Shift+O>

The commands you will probably want would include:

print {variable} - Displays the value of a variable (or at least lets you know it doesn't exist).
{variable} = {value} - Change the value of a variable.
watch {variable} - Add the named variable to the watch list (a box shown on the screen at all times).
unwatch {variable} - Remove the named variable from the watch list.

Pressing <ESC> will exit from the console back to the game.

If you've enabled Developer Mode too - you can also press <Shift+D> to bring up the developer menu. On that menu is [Variable Viewer] - which will list all the current game variables and their values. You'd still need to use the console to change any values, but it will at least tell you all the variables that exist at that moment of gameplay.

Personally, I've taken to just adding a custom script file to a game's /game/ folder, which sets some game defaults I like as well as enabling both the console and developer menus. (In much the same way that UnRen does, but with a couple of extra bits, like setting up a keybind for toggling auto-advance). Feel free to borrow any or all of it.
 

Zack99

Newbie
Jan 14, 2018
17
7
Nope.

It's because they make this shit up as they go along. They add something that needs a variable, they add that variable there and then. Invariably they're also just copying how someone else did it in the past.
Also, if they are releasing their game in chapters/days/versions, then there's already a version of that game out in the wild that doesn't include the variable... so depending on their level of knowledge - they keep it simple by only creating variables when they need them.
There is of course a better way... which is to create variables using the default statement - which ignores where in the code the variable is created and instead creates all variables using default before the game starts.


This would be HIGHLY unlikely. There's a lot of crap code out there, so I'm not saying impossible - but still unlikely.

Games crash if they reference a variable that hasn't been created. So usually, even if a variable is exclusive to a particular path - even the most inept developers only reference that variable if the other variables/choices that led to that path are met.

Much more common is that the variable is created but never given a value that makes sense, dependent on player choices.

By which I mean, I think you may be worried about a combination of circumstances which are more theoretical than practical.


The most common solution would be to enable the console and use console commands to add/modify variables

UnRen will do it for you if need be. (Make sure you use the 0.9 dev version, as recent improvements to RenPy mean that 0.8 doesn't always work).
Then open the console while the game is running. <Shift+O>

The commands you will probably want would include:

print {variable} - Displays the value of a variable (or at least lets you know it doesn't exist).
{variable} = {value} - Change the value of a variable.
watch {variable} - Add the named variable to the watch list (a box shown on the screen at all times).
unwatch {variable} - Remove the named variable from the watch list.

Pressing <ESC> will exit from the console back to the game.

If you've enabled Developer Mode too - you can also press <Shift+D> to bring up the developer menu. On that menu is [Variable Viewer] - which will list all the current game variables and their values. You'd still need to use the console to change any values, but it will at least tell you all the variables that exist at that moment of gameplay.

Personally, I've taken to just adding a custom script file to a game's /game/ folder, which sets some game defaults I like as well as enabling both the console and developer menus. (In much the same way that UnRen does, but with a couple of extra bits, like setting up a keybind for toggling auto-advance). Feel free to borrow any or all of it.
Ok thanks for the explanation, I will try the codes and files suggested, and see if I can make it work from there.