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.
I am having trouble giving affection points to characters in my game. In earlier lines of code, it works for some characters, but for the two I am trying to add, it is not working. It keeps coming up with the same 'undefined' message. I am having trouble trying to figure out what is wrong. Any help would be appreciated.
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 343, in script
$jane_aff -= 2
File "game/script.rpy", line 343, in <module>
$jane_aff -= 2
NameError: name 'jane_aff' is not defined
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/script.rpy", line 343, in script
$jane_aff -= 2
File "D:\renpy-7.1.1-sdk\renpy\ast.py", line 882, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "D:\renpy-7.1.1-sdk\renpy\python.py", line 1913, in py_exec_bytecode
exec bytecode in globals, locals
File "game/script.rpy", line 343, in <module>
$jane_aff -= 2
NameError: name 'jane_aff' is not defined
Windows-7-6.1.7601-SP1
Ren'Py 7.1.1.929
The Clusterf*** that is my Love-Life 1.0
Wed Jan 09 13:40:35 2019
It says that jane_aff is not defined.
Somewhere before the start label have you defined that variable using default?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
I have no experience using "default", so if that doesn't work you could always try using "define" instead.
Regardless, if neither works, there's most likely an issue somewhere else. Are mom_aff and sis_aff used less or more than best_aff and jane_aff? I'd recommend swapping some of your variables (KEEP A LOG ON WHICH ONES YOU ARE DOING THIS TO) to see if they are interchangeable. If they are, there is nothing wrong with the variable but instead what you are trying to do with the variable.
One should never use define for variables that will change, only default. Things get messed up otherwise.
If after making sure your variables are defined using default before the start label, if there are still problems--but only with one variable--the next most likely cause is a spelling inconsistency. jane_aff in the definition, Jane_aff later, for example.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)