Stats in their own file.

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
User avatar
Bum_McFluff
Regular
Posts: 45
Joined: Sat Aug 18, 2018 8:15 pm
Contact:

Stats in their own file.

#1 Post by Bum_McFluff »

I asked about multiple files elsewhere, but this is specific to stats. If I want a game where character will be faced with different types of choices and actions, eg how much money they have, their level of corruption, level of strength etc, it is better to have a separate file to list these stats? Something like stats.rpy? If, for example, by getting to +10 strength, the character qualifies as 'strong', does it make sense to have a list of how the characters start out?

$ Bob_Money = 0
$ Bob_Corruption = 0
$ Bob_Strength = 0

And also the result of reaching certain levels in each stat? For example:

$ if Bob_Strength == <1:
$ Bob = Weak
$ if Bob_Strength == 10:
$ Bob = Strong
$ if Bob_Strength == >10:
$ Bob= Very Strong

It seems to me if all of this was in one place, it would make everything easier, but as I am still new, I may be making trouble for myself without knowing it.

If this is not clear, it's likely there is a better way of explaining it, but I may not have the best grasp on Ren'Py language yet.
What, spy on our spy as he searches for their spy? Why not, sounds rather like fun.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Stats in their own file.

#2 Post by Imperf3kt »

As mentioned in your other thread, having things separate makes no discernible difference, but it does make it a bit easier on you as the developer to browse and edit your files.

imagine a 500,000 line file, scrolling all the way back to the top every time you want to add a new variable will be much easier if said stat was simply in a different file.

Or trying to find a specific section of dialogue or code without the help of the find tool.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Stats in their own file.

#3 Post by trooper6 »

Please remember, you initialize variables that you plan on changing like so:

default bob_money = 0

not

$ bob_money = 0
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
Bum_McFluff
Regular
Posts: 45
Joined: Sat Aug 18, 2018 8:15 pm
Contact:

Re: Stats in their own file.

#4 Post by Bum_McFluff »

trooper6 wrote: Wed Feb 12, 2020 2:11 am Please remember, you initialize variables that you plan on changing like so:

default bob_money = 0

not

$ bob_money = 0
Thanks for that. I appreciate it.
What, spy on our spy as he searches for their spy? Why not, sounds rather like fun.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Stats in their own file.

#5 Post by trooper6 »

And that should be outside of any block of code.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Post Reply

Who is online

Users browsing this forum: Google [Bot], Google Feedfetcher