reset of variable when main menu

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.
Post Reply
Message
Author
User avatar
Mirrodin
Regular
Posts: 114
Joined: Sun Mar 19, 2017 2:56 pm
Contact:

reset of variable when main menu

#1 Post by Mirrodin »

I have a variable wich reset itself each time I go on menu
I tried this but, no way, the variable resets even when it already has a value

Code: Select all

init -1 python:
    devmod = False
    devbuild = False
try:
    test_v
except NameError:
    test_v = "standart"

User avatar
Alex
Lemma-Class Veteran
Posts: 3093
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: reset of variable when main menu

#2 Post by Alex »

If you want to store your variable properly use default statement -https://www.renpy.org/doc/html/python.h ... -statement

If you need your variable to persist through different gameplays use persistent variables instead - https://www.renpy.org/doc/html/persistent.html

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: reset of variable when main menu

#3 Post by Imperf3kt »

Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Post Reply

Who is online

Users browsing this forum: WladekProd