Name not defined error! 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
User avatar
fukairi
Newbie
Posts: 18
Joined: Sun Nov 05, 2017 1:30 pm
Projects: NSE crap, Shadow Wolf project.
Tumblr: Marinut
Deviantart: Fukairi
Contact:

Name not defined error! Help :(

#1 Post by fukairi » Sun Nov 05, 2017 1:41 pm

Okay, so, I'm getting very close to getting my visual novel test complete, but I've run into an annoying error.

Error code:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 1610, in script
    menu:
  File "game/script.rpy", line 1616, in <module>
    "Deny" if Denial == True:
NameError: name 'Denial' is not defined

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

Full traceback:
  File "game/script.rpy", line 1610, in script
    menu:
  File "D:\Renpy\renpy-6.99.12.4-sdk\renpy\ast.py", line 1459, in execute
    choice = renpy.exports.menu(choices, self.set)
  File "D:\Renpy\renpy-6.99.12.4-sdk\renpy\exports.py", line 828, in menu
    if renpy.python.py_eval(condition) ]
  File "D:\Renpy\renpy-6.99.12.4-sdk\renpy\python.py", line 1749, in py_eval
    return py_eval_bytecode(code, globals, locals)
  File "D:\Renpy\renpy-6.99.12.4-sdk\renpy\python.py", line 1743, in py_eval_bytecode
    return eval(bytecode, globals, locals)
  File "game/script.rpy", line 1616, in <module>
    "Deny" if Denial == True:
NameError: name 'Denial' is not defined

Windows-8-6.2.9200
Ren'Py 6.99.12.4.2187
NSE: Halloween Special 1.4
So this is part of the code right after the start label;

Code: Select all

#Major events
$ Bad_End = False
$ Tea_Party = False
$ Claustrophobia = False
$ Floating = False
$ Denial = False
^As you can see the last one sets the event "Denial" as false.

So here's a check before a menu option;

Code: Select all

if Tea_Party == True:
    if Claustrophobia == True:
        $ Denial = True
This is supposed to check if two previous events are set to true, in order for a menu option to either be hidden or not. I feel like this is the issue, even though ren'py claims the menu option is causing the error.

Code: Select all

menu:

      
        "Fight":
            jump MarcusFight

        "Deny" if Denial == True:
            jump MarcusDeny

        "Panic":
            $ Bad_End_Points += 1
            $ Random_Points += 1
            jump MarcusPanic
^Here's the menu option. Deny is supposed to show up only if claustrophobia & tea_party are set to true. I probably made this in a really dumb way, but I am just a nab :(
Any help will be greatly appreciated!
Bap.

User avatar
mitoky
Veteran
Posts: 316
Joined: Sat Feb 07, 2015 9:12 pm
Projects: The Purring Demon's Love, circus eterie
Contact:

Re: Name not defined error! Help :(

#2 Post by mitoky » Sun Nov 05, 2017 2:07 pm

I think the problem is that you are not using low-case letters only for the variables so you should change that.

Its better to define your variables with default before start like this:

Code: Select all

default bad_end = False
default tea_party = False
default claustrophobia = False
default floating = False
default denial = False

label start:
and you can check if the variables are true in one line:

Code: Select all

if tea_party and claustrophobia:
    $ denial = True
and in the menu:

Code: Select all

menu:

        "Fight":
            jump MarcusFight

        "Deny" if denial:
            jump MarcusDeny

        "Panic":
            $ bad_end_points += 1
            $ random_points += 1
            jump MarcusPanic
And i think that should work.

User avatar
fukairi
Newbie
Posts: 18
Joined: Sun Nov 05, 2017 1:30 pm
Projects: NSE crap, Shadow Wolf project.
Tumblr: Marinut
Deviantart: Fukairi
Contact:

Re: Name not defined error! Help :(

#3 Post by fukairi » Sun Nov 05, 2017 2:34 pm

mitoky wrote:
Sun Nov 05, 2017 2:07 pm
I think the problem is that you are not using low-case letters only for the variables so you should change that.

Its better to define your variables with default before start like this:

Code: Select all

default bad_end = False
default tea_party = False
default claustrophobia = False
default floating = False
default denial = False

label start:
and you can check if the variables are true in one line:

Code: Select all

if tea_party and claustrophobia:
    $ denial = True
and in the menu:

Code: Select all

menu:

        "Fight":
            jump MarcusFight

        "Deny" if denial:
            jump MarcusDeny

        "Panic":
            $ bad_end_points += 1
            $ random_points += 1
            jump MarcusPanic
And i think that should work.
That worked, thank you!!
Bap.

Post Reply

Who is online

Users browsing this forum: No registered users