saving static values/classes

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
Ayutac
Regular
Posts: 150
Joined: Thu Oct 18, 2012 2:23 pm
Projects: Pokémon Dating Sim
Organization: A Breeze Of Science
Deviantart: Ubro
Location: Mayence, Germany
Contact:

saving static values/classes

#1 Post by Ayutac » Wed Nov 06, 2013 3:53 am

So far I only had instances of objects and got the saving work by deriving from store.object. But does this also work for static values which are not constants? I'm planning on making a static class because else only one instance would be needed and there would be several points where I would have to import it with global.
Or is it just a bad idea to operate with static classes in Ren'Py or Python?
Up next: An original, open source, text-based Dating Sim. Stay tuned ;)

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: saving static values/classes

#2 Post by xela » Wed Nov 06, 2013 7:08 am

It's not a very useful idea I expect, there is little to be gained by using using a static class in Python. If you decide to use one, make sure it is declared in a label, not init since it's values are not meant to be constants (they will be overwritten even if you inherit from store.object otherwise). So in short, in order to get variables in your static class to save you'll either have to declare it in in label or write a save/load function to store/load the data somewhere where it's safe.

I never tried this myself, but I do expect it to work like this.
Like what we're doing? Support us at:
Image

Post Reply

Who is online

Users browsing this forum: Google [Bot], _ticlock_