Tracking character approval of player

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
MiaCorvere
Newbie
Posts: 9
Joined: Sun Dec 01, 2019 12:47 pm
Tumblr: https://arent-we-all-game.tumblr
Contact:

Tracking character approval of player

#1 Post by MiaCorvere »

If I want to track how much a character likes the player, do I have to use persistent variables to store that data? My idea is that I have a variable for each character and depending on which dialogue options you pick, I add a number to that variable. If the number is high enough, you get a bonus dialogue option in some menus or extra scenes. But I'm a bit unsure how to define variables like that so that the progress is saved between play sessions

User avatar
m_from_space
Miko-Class Veteran
Posts: 975
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Tracking character approval of player

#2 Post by m_from_space »

MiaCorvere wrote: Wed Jan 17, 2024 6:18 pm If I want to track how much a character likes the player, do I have to use persistent variables to store that data? My idea is that I have a variable for each character and depending on which dialogue options you pick, I add a number to that variable. If the number is high enough, you get a bonus dialogue option in some menus or extra scenes. But I'm a bit unsure how to define variables like that so that the progress is saved between play sessions
I think I should maybe make a simple guide regarding variables in Renpy soon.

No, you don't have to use a persistent variable for that. Persistent variables are useful for stuff outside of a game, like a gallery or achievements in the main menu. They "persist" even if you are not inside a game and are shared by all games (even those of different players on one pc or phone). So for example with a persistent variable you could count how often your game was started since the player installed it.

As for your question, just create a variable using default and Renpy will automatically save changes you made throughout the game. It will also set this variable to this default value every time a new game begins. Just think of "default" variables as variables per-game (per-save).

Code: Select all

# how much Eileen trusts the player
default eileen_trust = 0
Whenever you need a variable that won't change (and therefore doesn't need to be saved), use define instead. That's it. Only use default and define. Do not create variables within init python or init blocks.

MiaCorvere
Newbie
Posts: 9
Joined: Sun Dec 01, 2019 12:47 pm
Tumblr: https://arent-we-all-game.tumblr
Contact:

Re: Tracking character approval of player

#3 Post by MiaCorvere »

Thank you, that helps a lot!

Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot]