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 »

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
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Help. Variable not defined

#2 Post by Imperf3kt »

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.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Majestic-12 [Bot]