I want to learn more about named stores in Ren'Py. Is it similar to the concept of namespaces in other programming languages? Can it be used in a way to organize global variables and functions?
For example, my game is composed of story/VN and RPG battle segments. Possibly the battle parts will have a lot of variables that pertain to it but not necessarily outside of battle. I could have turn orders, status ailments, battle formations, etc. in the global variables, but it might seem cluttered to have them around during the story segnents. What are the advantages and disadvantages in creating a named store for battle variables and functions for this example?
Named store
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.
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.
- PyTom
- Ren'Py Creator
- Posts: 16096
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: Named store
They're like namespaces in other programming languages.
The main downside is they're fairly incomplete - at this point, there's no way for a screen or a text substitution to access a named store except using its name.
The main downside is they're fairly incomplete - at this point, there's no way for a screen or a text substitution to access a named store except using its name.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
- SinnyROM
- Regular
- Posts: 166
- Joined: Mon Jul 08, 2013 12:25 am
- Projects: Blue Birth
- Organization: Cosmic Static Games
- Contact:
Re: Named store
Great. I'm a little confused on what you mean by no way of accessing except by name though. This is what I have from the example documentation which shows the correct values without complaint - unless I'm thinking of something else entirely.
Code: Select all
screen debug():
frame:
has vbox
text "variable: [variable]"
text "mystore.variable: [mystore.variable]"
init python in mystore:
variable = 0
init python:
import store.mystore as mystore
label start:
show screen debug
$ variable = 1
"Showing variables with a screen"
"variable: [variable]"
"mystore.variable: [mystore.variable]"
Who is online
Users browsing this forum: Google [Bot]