Adding stats and old saves

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
numaej
Newbie
Posts: 22
Joined: Fri Dec 21, 2018 9:24 am
Contact:

Adding stats and old saves

#1 Post by numaej » Fri Aug 23, 2019 1:32 am

Let's start off from marking that I'm a newbie when it comes down to coding. Game I'm working on is an VN but with few different paths. Now this is the question I've been struggling a lot lately: how to implement new stats to the code while not forcing players to have a fresh start. Recently, I found out about lambdas, I won't lie I have no idea what is that, been looking at the code like I'd be looking at some mystery dark magic. The premise seems really interesting, few people mentioned about a possibility to change a stat from the past and not causing any errors in the old saves. Also, you can add as many stats as you want even in the past code [by that I mean that if down the road you change your mind about some event that already took place in your game, for example to make it less crucial for the story, you can change its value or add some more stats to it if necessary].

I've been wondering about it, because I want to have some backup plan for the future. New update of my game will force players to start over, but this time I want to be prepared for any further changes in next updates. Mainly, I'm talking about the stats. Each new update introduces new character, which if players want, story might be developed. And now I'm really trying to find a solution and, as I mentioned, to be prepared for the future choices of the players. It's truly a real challenge for a newbie like me. I can't guess which characters will gain my players attention and which will not.
As a newbie I first thought about adding a ton of stats like this:

$ x_affection = 0
$ x2_affection = 0
$ x3_affection = 0
$ x4_affection = 0
$ x5_affection = 0
(...)
$ y_affection=0
$ y2_affection=0
(...)

But as you may see, it'll be really easy to get confused while working on a new update. I know, that a lot of you might find it silly, but I really have no clue how to solve this.

User avatar
Angelo Seraphim
Regular
Posts: 32
Joined: Tue May 21, 2019 8:00 am
Completed: Enamored Risks (NaNoReNo 2020)
Projects: 616 Charagma
Organization: GLSUoA
Deviantart: glsuoa
itch: glsuoa
Location: London, UK
Discord: Just A Concept#9599
Contact:

Re: Adding stats and old saves

#2 Post by Angelo Seraphim » Fri Aug 23, 2019 2:57 am

Image

numaej
Newbie
Posts: 22
Joined: Fri Dec 21, 2018 9:24 am
Contact:

Re: Adding stats and old saves

#3 Post by numaej » Fri Aug 23, 2019 2:19 pm

This is probably it. But it brings another newbie question: how the hell I can built stats system on it?

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Adding stats and old saves

#4 Post by namastaii » Fri Aug 23, 2019 2:41 pm

You would define your stat variables as persistent variables

Code: Select all

default persistent.x_affection = 0

numaej
Newbie
Posts: 22
Joined: Fri Dec 21, 2018 9:24 am
Contact:

Re: Adding stats and old saves

#5 Post by numaej » Fri Aug 23, 2019 3:12 pm

Okay, and how to add points to it later?

like this?

Code: Select all

menu:
        "HIDE":
            $ x_hate += 1
            $ y_hate += 1
            jump hide

        "DON'T HIDE":
            $ x_affection += 1
            $ y_affection += 1
            jump donthide
adding new persistent later on in a new update will not crush the game, right?

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Adding stats and old saves

#6 Post by namastaii » Fri Aug 23, 2019 3:16 pm

I believe you still have to put persistent in front of the variable when you increment or call it

I don't know much about game updates and persistent

Post Reply

Who is online

Users browsing this forum: No registered users