NameError: name not defined?

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
ezzy-rezzy
Newbie
Posts: 8
Joined: Tue Apr 10, 2018 8:03 am
Skype: live:emaafre
Contact:

NameError: name not defined?

#1 Post by ezzy-rezzy »

Hi everyone. I've only been using Ren'Py for a few days now, and I'm really enjoying it. However, I've run into a problem that I just don't know how to fix.

So it keeps giving me this error:

I'm sorry, but an uncaught exception occurred.

While running game code:
File "game/script.rpy", line 890, in script
define date = jacob
File "game/script.rpy", line 890, in <module>
define date = jacob
NameError: name 'jacob' is not defined

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

# Full traceback:
File "game/script.rpy", line 890, in script
define date = jacob
File "C:\Users\Sue\Desktop\renpy-6.99.14.3-sdk\renpy\ast.py", line 1946, in execute
value = renpy.python.py_eval_bytecode(self.code.bytecode)
File "C:\Users\Sue\Desktop\renpy-6.99.14.3-sdk\renpy\python.py", line 1912, in py_eval_bytecode
return eval(bytecode, globals, locals)
File "game/script.rpy", line 890, in <module>
define date = jacob
NameError: name 'jacob' is not defined

It says to define name 'jacob' right? Well, you can see how this confuses the heck out of me, seeing that 'jacob' is not something that needs to be defined?

Here's the script at that point. It's a menu.

And I've tried putting a dollar sign instead of "define". It then tells me to define date.

Code: Select all

   menu:
        "Jacob":
            jump choice_jacob
            define date = jacob
        "Rylee":
            jump choice_rylee
            define date = rylee
        "Troy":
            jump choice_troy
            define date = troy
        "Kaiko":
            jump choice_kaiko
            define date = kaiko

DannX
Regular
Posts: 99
Joined: Mon Mar 12, 2018 11:15 am
Contact:

Re: NameError: name not defined?

#2 Post by DannX »

Define in this case means to create a variable. You only need to do that once, and it's probably a good idea to do so with default statement instead of define.

As for the error, it's because you're trying to set date to a variable called jacob, but since that variable hasn't been created, it throws the undefined error. You either need to create the variable first, or maybe make 'jacob' a string. The same for the rest of characters. When you set a variable to a word without quotation marks (' ' or " "), ren'py interprets it as a variable. If you do use the marks it interprets it as a string of characters.

Code: Select all

default date = None #create the variable called date, with None as default value.

label start:

    menu:
        "Jacob":
            $ date = 'jacob' #set the variable date to value 'jacob', a string
            jump choice_jacob #then jump to choice_jacob label 

ezzy-rezzy
Newbie
Posts: 8
Joined: Tue Apr 10, 2018 8:03 am
Skype: live:emaafre
Contact:

Re: NameError: name not defined?

#3 Post by ezzy-rezzy »

DannX wrote: Tue Apr 10, 2018 8:36 am Define in this case means to create a variable. You only need to do that once, and it's probably a good idea to do so with default statement instead of define.

As for the error, it's because you're trying to set date to a variable called jacob, but since that variable hasn't been created, it throws the undefined error. You either need to create the variable first, or maybe make 'jacob' a string. The same for the rest of characters. When you set a variable to a word without quotation marks (' ' or " "), ren'py interprets it as a variable. If you do use the marks it interprets it as a string of characters.

Code: Select all

default date = None #create the variable called date, with None as default value.

label start:

    menu:
        "Jacob":
            $ date = 'jacob' #set the variable date to value 'jacob', a string
            jump choice_jacob #then jump to choice_jacob label 
Thank you!! That fixed it!! :D

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], voluorem