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 was running my script for a calendar changer and I noticed that %s isn't working anymore. What gives? First it's not finding the variable, put it inside a init and it's not replacing the image based on the variable.
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 3, in script
image cal_background = "cal_%s.png"%month
File "game/script.rpy", line 3, in <module>
image cal_background = "cal_%s.png"%month
NameError: name 'month' is not defined
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/script.rpy", line 3, in script
image cal_background = "cal_%s.png"%month
File "G:\Creative\VN\Renpy\renpy\ast.py", line 980, in execute
img = renpy.python.py_eval_bytecode(self.code.bytecode)
File "G:\Creative\VN\Renpy\renpy\python.py", line 1937, in py_eval_bytecode
return eval(bytecode, globals, locals)
File "game/script.rpy", line 3, in <module>
image cal_background = "cal_%s.png"%month
NameError: name 'month' is not defined
Windows-7-6.1.7601-SP1
Ren'Py 7.1.3.1092
small_calander 1.0
Tue Jan 22 21:05:33 2019
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?)
trooper6 wrote: ↑Wed Jan 23, 2019 1:31 am
Also % is Python script (though Python is now using format rather than %)...image is a Renpy line...so you can just do:
I reviewed my code and I think it was because I was trying to use add cal_background on my screen instead of just add "cal %s"%month. However, add "cal [month]" works in a screen as well. I am really not sure since I tossed the original code. However, when I do remember it telling me that month wasn't defined when I was using default month right before it on the screen.