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.
I'm using a variable to determine what will show in a phone chat. The way it works is that there's a Vbox and things show up based on the variable value, which is incremented by 1 everytime you click on the screen outside of the chat.
I'm declaring my variable in the script file, before anything else, at the top of the file as:
So, you start a new game and the value is 0 (as expected)
You load a save and the value is 0 (we'd expect it to retain the value it was when the save was done, so this is possibly expected too). You've not confirmed the save holds a different value so we do not know.
If you wanted it to maintain state between different play throughs, make it persistent. Pretty sure you do not want that though. I'd search your entire script(s) for var_chat and check you are not altering it elsewhere... Other than that, expected behaviour...
Note though that saving from a screen area (without an interaction) will not automatically update the variables value... Ren'Py only natively puts checkpoints at places in label flow that cause interactions... Perhaps close the screen, add a dialogue line and try saving after that is reached.
Hmm, it might be the problem with checkpoints then. Will try it.
And yes, I'm making it go up and saving and then closing but it's not saving the final value, but it might be the checkpoint thing. Any dialogue would do it?
Even a pause 0.01 should do it, so if you have no other logical way around it you could theoretically call a label that incremented the variable, paused minutely and returned...
(note that progression through labels should control game progression, not progression through screens... screens should really be for displaying things, not to control game progress)
If you use 'call' then you're passing the control to the screen and eventually you need to use the Screen Action called Return() to go back to the labels. Until Ren'Py hits the next label in the script, the variables won't save. If you use 'call' then perhaps rayminator's suggestion may help.
The way I force save when my game is fully based on screens, is to use 'Return' after the statement, then call the screen again from a centric label that I name 'continue_gameplay'. So the flow goes like this:
1) call screen
2) From screen, do action and Return()
3) in the lines after 'call screen' in the script, I put 'jump continue_gameplay'
4) I define label continue_gameplay to call the appropriate screen based on variable setting
Every time the label is visited, Ren'Py internally saves the data, even if you're always jumping to the same label.
and with "pause" between every increment but both ways just kept incrementing with every click infinitely ,instead of just 6 times, and the menu never showed up.
I know this isn't the topic main subject but if it's a simple fix could anyone explain what I should do?
I'd be a little shocked if this ever ran. Generally, the SayBehavior - which is what handles the dismiss key - will terminate the interaction before the screen processes this. As a result, SetVariable will never be called, and so var_chat will not increment.
I'd suggest using a character callback for this, perhaps something like:
init python:
def bump_var_chat(event, interact=True, **kwargs):
global var_chat
if not interact:
return
if event == "end":
var_chat += 1
config.all_character_callbacks.append(bump_var_chat)
Supporting creators since 2004 (When was the last time you backed up your game?)