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.
Hi! I'm sorry if you saw me too often. I was playing around with renpy and python, so i tried to access a python class in renpy. I want to get user input for the numbers, but somehow it didn't work, Btw i know this code isn't applied for visual novel, i just took an easiest example to tested out. So here's my code
The slightly “more Ren’py way” of doing this is to move the class to an “init python” block (instead of just a “python” one). That way, the class definition will be set up before any of your script is run. (All the “init” stuff is done before any script runs, so you can put it in its own file if you want)
Yeah, class definitions shouldn't be inside the start label.
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?)
Some things shouldn't be classes. But just labels that you call.
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?)
Again, the “more Ren’py way” would be to separate the functions - ask for input using “normal” script, and then if you need a class to use that info, pass it to the class via a $ line or an in-line Python block. What happens if you need to update the class between 0.1 and 0.2? The way you’ve done it, someone with a save won’t get the updates, because they will be past that block of Python.
As trooper6 quite correctly points out, you can create callable sections of Ren’py script if you need reusable script-based “stuff.”