Python & Renpy = PHP & CSS ?

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
CSK
Newbie
Posts: 15
Joined: Sat Sep 10, 2022 2:42 pm
Contact:

Python & Renpy = PHP & CSS ?

#1 Post by CSK » Sat Sep 24, 2022 11:58 am

Hoping what I used in the subject is correct and makes sense, while I haven't managed to find anything on it, which could be due to my lack of knowing what to sensibly search for, I am still assuming no, but could still be that it is actually obvious. So, what I am interested in is whether it would be possible to for example have something like this:

Code: Select all

scene eye_blink
show black with dissolve
pause 0.1
hide black with dissolve
pause 0.2
show black with dissolve
pause 0.1
hide black with dissolve
pause 0.3
show black with dissolve
Instead of like this, which can just be posted into the normal Renpy mode, have that whole thing instead in a Python function. That just being a simple example, but lets say there is a bit more elaborate notify pop up that is needed a lot throughout a story, which requires several lines like the example, it would be much neater if it was possible to reduce the amount of lines by putting them into a function. Or when having several variables in a function, I know that can be done with a function to present it as a simple list, but is it possible to add things like "vbox" and such as well? It's not that I would mind to create the structure in Renpy and then fill in the variables in respectively, or to just copy paste the lines for notify pop ups or blinking, which I already know how to do, but if it is possible I rather do it via Python. I am aware that it is to some degree possible, as even just creating a list and being able to add a {p} in it creates some structure, so my question is whether it is possible to do so to a much bigger degree, and if so if there is a guide or a list of commands specific for it. With the little I found I wasn't able to do much, apart from creating error messages, but that could just be me and not because it's not possible.

Also, apologies that the question is such a mess, I like to think that if I knew more of the relevant vocabulary that it would be at least somewhat more precise.

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1882
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Python & Renpy = PHP & CSS ?

#2 Post by Ocelot » Sat Sep 24, 2022 1:42 pm

1) you can call specific labels for specific scenes and even pass argument to them
2) you can define sequences of animation controlled by arguments.
3) You can define screens with animations and arguments
something like:

Code: Select all

label scary_scene(times=5):
    scene
    show eye_blink
    show black with dissolve
    while times > 0:
        pause renpy.random.choice((0.1, 0.2, 0.1, 0.3))
        hide black with dissolve
        pause renpy.random.choice((0.1, 0.2, 0.1, 0.3))
        show black with dissolve
    return

# . . .
call scary_scene(times=2)
While you can do that mostly in Python, it will be way more verbose (I believe, code snippet ypou posted alone would be more than 100 lines of code to get to behave identically)
< < insert Rick Cook quote here > >

CSK
Newbie
Posts: 15
Joined: Sat Sep 10, 2022 2:42 pm
Contact:

Re: Python & Renpy = PHP & CSS ?

#3 Post by CSK » Sat Sep 24, 2022 1:58 pm

Perfect, with that I know what to play around with and what to look into for it. Thanks!

Post Reply

Who is online

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