That would be quite unusual and I wonder if perhaps there's another misunderstanding going on here.
"
Usually" ...
show screen
is used to put a
screen
onto the display and just leave it there. The usual use case would be something like a status bar.
Where you want the player to interact with the game to trigger an action, you would use
call screen
.
We've seen people make the mistake of using
show screen
and
$ renpy.pause(hard=True)
- which doesn't actually work how they think it does (The hard pause doesn't STOP the game awaiting interaction, and depending on what the player is doing, very unexpected things can happen). I don't think that's happening with you... but it is worth a mention, just in case.
We've also seen people who don't put all their interactions within a single screen and end up feeling they need to use
show screen
multiple times - because that's the only way they can see to do it. Sometimes it has been as bad a one
imagebutton
per
screen
. I don't think you're doing anything quite that bad, but I do wonder if you're doing something like that.
One way to solve it is by using
You must be registered to see the links
. Where a single master
screen
can incorporate one or more other
screens
. The RenPy main menus use this, so things like the "Save" and "Options" screens only need to be defined once, but used in multiple places. Though as I've strongly hinted at earlier, it's much better for newer RenPy developers to put all your interactive buttons and such on to a single
screen
and use
call screen
. If not all buttons are visible all the time, there's always
You must be registered to see the links
.
Another way (not ideal), is to use something like:
Python:
show screen myscreen1
call screen myscreen2
Where you use
show screen
to show all but the "last" screen. The use
call screen
to show the final one (and by doing so, cause the script to wait for a player interaction - though only the
action
s that are part of the final screen will cause the script to move on. Hence my "not ideal" comment.
That would usually how you'd reference a variable within a function. Though you've already mentioned that it does work later.
But using your example, I'd expect to see something like...
Python:
default testVar = 0
init python:
def increase():
store.testVar += 1
screen testButton:
button:
add "poorHomeFoodIcon"
pos (0.48,0.45)
text "{color=#fff}x[testVar]{/color}" size 20:
yoffset -18
xoffset +18
action Function("increase")
label start:
"1"
call screen testButton
"2 (save here)"
return
You seem adverse to using
You must be registered to see the links
, since you need to affect multiple variables. Although that is simple enough...
Python:
screen testButton:
button:
add "poorHomeFoodIcon"
pos (0.48,0.45)
text "{color=#fff}x[testVar]{/color}" size 20:
yoffset -18
xoffset +18
action [SetVariable(testVar1, testVar1 + 1), SetVariable(testVar2, testVar2 + 1), SetVariable(testVar3, testVar3 + 1)]
Multiple actions can be chained together by including them in a list (
[ ]
).
Of course, this is very simplistic - and you may need the actual
Function
to do more complex calculations.
A quick note: I'd don't currently have access to RenPy. So all the above code is untested and purely based on my experience and access to the RenPy manual pages. It's a "I think it works", rather than "I know it works".