Error when Creating Flags - Help

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
exax
Newbie
Posts: 9
Joined: Thu Jan 05, 2017 3:39 am
Contact:

Error when Creating Flags - Help

#1 Post by exax »

I am currently writing a Visual Novel and need to establish a fair number of flags.
However, I am having trouble recalling the flags.

In the first script
label note_2:
if note1 == "no_go":
$ hano_flag_1 = True
jump note2_home
In a later script
menu:
"Hano" if hano_flag_1 == True:
$ hano_flag_2 = True
jump note4_afternoon


Error
I'm sorry, but an uncaught exception occurred.

While running game code:
File "game/scripts/note_4.rpy", line 322, in script
menu:
File "game/scripts/note_4.rpy", line 328, in <module>
"Hano" if hano_flag_1 == True:
NameError: name 'hano_flag_1' is not defined

-- Full Traceback ------------------------------------------------------------

Full traceback:
File "game/scripts/note_4.rpy", line 322, in script
menu:
File "C:\Program Files\renpy\renpy-6.99.4-sdk\renpy\ast.py", line 1411, in execute
choice = renpy.exports.menu(choices, self.set)
File "C:\Program Files\renpy\renpy-6.99.4-sdk\renpy\exports.py", line 714, in menu
if renpy.python.py_eval(condition) ]
File "C:\Program Files\renpy\renpy-6.99.4-sdk\renpy\python.py", line 1482, in py_eval
return eval(py_compile(source, 'eval'), globals, locals)
File "game/scripts/note_4.rpy", line 328, in <module>
"Hano" if hano_flag_1 == True:
NameError: name 'hano_flag_1' is not defined

Windows-8-6.2.9200
Ren'Py 6.99.4.467
TRUMPET 1.2 0.0

Note
- The same error occurs when I tried to use $ flag = "Yes" or other alternatives names
- The same error occurs when the ($ X = True ) statement and (if X == True) statement in the same script file
- The same error occurs when the ($ X = "Y" ) statement and (if X == "Y") statement in the same script file


Please help me identify the problem >___<

exax
Newbie
Posts: 9
Joined: Thu Jan 05, 2017 3:39 am
Contact:

Re: Error when Creating Flags - Help

#2 Post by exax »

Note: The indentation is not showing in the quotes, but the script is properly indented

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2399
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Error when Creating Flags - Help

#3 Post by Ocelot »

Use code tage, not quote tag.

What do you think would happen if somebody will not hit the line setting variable to True? What would be the value of the variable in this case?

You need to make sure that variable always has some value assigned to it. Easiest way do do so is to give it a default value:

Code: Select all

# Outside of any context, even init statements
default hano_flag_1 = False
< < insert Rick Cook quote here > >

exax
Newbie
Posts: 9
Joined: Thu Jan 05, 2017 3:39 am
Contact:

Re: Error when Creating Flags - Help

#4 Post by exax »

Ocelot wrote:Use code tage, not quote tag.

What do you think would happen if somebody will not hit the line setting variable to True? What would be the value of the variable in this case?

You need to make sure that variable always has some value assigned to it. Easiest way do do so is to give it a default value:

Code: Select all

# Outside of any context, even init statements
default hano_flag_1 = False
!!! I forgot about the False value !!!
Thank you so much !

Post Reply

Who is online

Users browsing this forum: No registered users