What I wanted to do was create some "always-available" options. Two examples would be
a) A 'cyclopedia' that I could summon at any time to look up topics or histories;
b) A special option where I could at any time.. oh.. let's say "commune with my goddess, and after a short conversation, gain some new inner strength that I could take back to the conversation at hand."
Option a isn't too much trouble.
Code: Select all
image encyclopediabutton = Button(Text("Encyclopedia"),clicked=ui.callsinnewcontext("AClicked"))
# and then
show encyclopediabutton at Position(xalign=0.1, yalign=0.1)
# and then
label AClicked:
hide encyclopediabutton
nvl clear
definition "We're pretending that this is an encyclopedia section."
definition "Done? Good."
show encyclopediabutton
return
Code: Select all
image goddessbutton = Button(Text("Commune With Goddess"),clicked=ui.callsinnewcontext("Goddess"))
# and then
show goddessbutton at Position(xalign=0.1, yalign=0.1)
# and then
label Goddess:
hide goddessbutton
nvl clear
"The present moment freezes, and then fades away into darkness."
"Goddess" "So, Tetsuo, you've come again to pray to me?"
if wishcount > 0:
"Goddess" "So be it. Let me give you the strength you need."
$wishcount -= 1
$tetsuo_innerstrength += 10
if wishcount == 0:
"Goddess" "But from now on, you're on your own."
show goddessbutton
return
This is even when those variables were defined at the main thread in the first place.
It downright confused me why that would be, until I did some studying and realized that Ren'py doesn't so much save the top-level context as watches it carefully, and notes any changes - and apparently, only notes them when the top context is running.
I found you could force Ren'py to save accurately by doing this:
Code: Select all
$wishcount = wishcount
$tetsuo_innerstrength = tetsuo_innerstrength
I tried a few things. I read using renpy.dynamic to mark variables, and tried setting vars(renpy.store) directly from inside the new context, but in either case, there still was a discrepancy.
How can I get the save tracker to notice variable changes in a different context?