Help. Variable 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
volatilecomet
Newbie
Posts: 1
Joined: Sun Nov 19, 2017 3:01 am
Contact:

Help. Variable not defined

#1 Post by volatilecomet » Sun Nov 19, 2017 3:10 am

I have issues in the code below,

ERROR MESSAGE:
[issue] File "game/script.rpy", line 5, in keywords
vbox:
File "<screen language>", line 5, in <module>
NameError: name 'totalval' is not definedscreen blah:
[/issue]


CODE:

screen blah:
hbox:
vbox:
imagebutton auto "right_%s.png" clicked SetVariable("totalval", totalval + 1) # action blah blah
imagebutton auto "right_%s.png" action NullAction
imagebutton auto "wrong_%s.png" action NullAction
vbox:
imagebutton auto "wrong_%s.png" action NullAction# action blah blah
imagebutton auto "right_%s.png" action NullAction
imagebutton auto "wrong_%s.png" action NullAction
vbox:
imagebutton auto "wrong_%s.png" action NullAction# action blah blah
imagebutton auto "right_%s.png" action NullAction
imagebutton auto "right_%s.png" action NullAction
define r = Character('Amanda')

label start:
$totalval = 1
r "Hello"
show screen blah
r "bye"
return


Please help me I donno what I am doing wrong here..

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

Re: Help. Variable not defined

#2 Post by Imperf3kt » Sun Nov 19, 2017 3:35 am

You need to move

Code: Select all

$totalval = 1
to before the start label as

Code: Select all

default totalval = 1
I'm not sure, but also check if 'setvalue' works like that.
Image

Warning: May contain trace amounts of gratuitous plot.

Post Reply

Who is online

Users browsing this forum: Lucky Duck