NameError name 'name' is 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
AndromedaDietrich
Newbie
Posts: 1
Joined: Fri Dec 28, 2018 4:00 pm
Tumblr: cloudedeternity
Deviantart: andromedadietrichart
Contact:

NameError name 'name' is not defined

#1 Post by AndromedaDietrich »

Hi! I'm entirely new to coding via ren'py, though I have been acquainted with games made via the engine before.
Note: Any indentation I do results in an "unexpected indentation" error.

# The script of the game goes in this file.

# Declare characters used by this game. The color argument colorizes the
# name of the character.

# The game starts here.

label start:
$ name=""

$name = renpy.input("What is your name?")
$name = name.strip()
if name = "none":
$ name = "You"

define e = Character("Everett")
define E = Character("Ebenezer")
define j = Character("Judson")
define h = Character("Hieronymous")
define uk = Character("????????")
define u = Character([name])


scene bg room


# These display lines of dialogue.

"Hello, [player_name]."

# This ends the game.

return


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

While running game code:
File "game/script.rpy", line 21, in script
define u = Character([name])
File "game/script.rpy", line 21, in <module>
define u = Character([name])
NameError: name 'name' is not defined

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

Full traceback:
File "game/script.rpy", line 21, in script
define u = Character([name])
File "C:\Users\tasos\Desktop\Renpy\renpy-7.1.3-sdk\renpy\ast.py", line 1979, in execute
value = renpy.python.py_eval_bytecode(self.code.bytecode)
File "C:\Users\tasos\Desktop\Renpy\renpy-7.1.3-sdk\renpy\python.py", line 1937, in py_eval_bytecode
return eval(bytecode, globals, locals)
File "game/script.rpy", line 21, in <module>
define u = Character([name])
NameError: name 'name' is not defined

Windows-8-6.2.9200
Ren'Py 7.1.3.1092
Untitledfornow 1.0
Fri Dec 28 15:18:21 2018

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

Re: NameError name 'name' is not defined

#2 Post by Alex »

Try to add this line of code

Code: Select all

default name = "???"
Hint: it doesn't matter where you put default and define statements - they will run before the start label, so it's more convinient to put all this lines together at the begining of the script (before start label).

Post Reply

Who is online

Users browsing this forum: Bing [Bot]