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 have variables that are only used in a screen. How should I declare those variables? Do they have to be declared outside of the screen or is it safe to declare variables within a screen?
#What is the proper way to declare screen only, local variables?
#Where should local scope, screen only variables be declared? Outside of screen or within?
screen testWindow:
vbox:
# should I declare screen only variables with default
default test_var1 = 0
# .... or $ ?
$ test_var2 = 0
If they are only used within the screen (including changing them) then yes, you should place them in the screen. Depending on what you are doing, you will actually need to do so in order for some things to update themselves properly.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Imperf3kt wrote: ↑Tue Nov 06, 2018 4:35 am
If they are only used within the screen (including changing them) then yes, you should place them in the screen. Depending on what you are doing, you will actually need to do so in order for some things to update themselves properly.
So far using $ seems to be important, since I need the variables to reset to False on every screen update. If I use default, the values get remembered and I lose the functionality I need.
Like you said, I think it depends on what you're doing if you use $ or default as declarations.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)