Character-specific variables

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
trismegistus
Newbie
Posts: 7
Joined: Mon Jul 04, 2016 4:02 pm
Contact:

Character-specific variables

#1 Post by trismegistus »

Let's say I have a lot of different characters, and I want to keep track of certain things about all of them (for example, whether you've met them yet, their opinion of you, that sort of thing). I could just create a separate variable per attribute per character, but that would get messy fast, and be difficult to iterate through, etc. Is there a way I can just add extra attributes to the Character class or something, ideally so I could just set up all these stats at once when I define the character, like:

Code: Select all

define v = Character('Victor', color="#c8ffc8", show_two_window=True, known=False, happiness=10)
...that sort of thing?

I don't know if trying to redefine the Character class is a bad idea, but being able to add onto it would be nice. Or maybe I could create my own class that's just a Character plus other stuff? Or a dictionary that's indexed by character and has all their relevant variables underneath that?

What's the typical way of doing this? It seems like something that would be pretty common, but a quick search of the documentation and this forum didn't turn up much.

Thanks

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: Character-specific variables

#2 Post by trooper6 »

This post may be useful for you:
viewtopic.php?p=415130#p415130
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]