Procedures? [Solved, thanks!]

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
moodykillmar
Newbie
Posts: 8
Joined: Sun Jun 11, 2017 12:27 pm
Contact:

Procedures? [Solved, thanks!]

#1 Post by moodykillmar »

I want to have something happen to an image every time I call it, and I know that in Python you can define procedures like that, but can you do it with Ren'Py? It would save a lot of space. I don't mind copy/pasting the functions, I just want to know if there's a better way to do it? A less cluttered way?

Code: Select all

show spell at truecenter:
zoom 2.0 
linear 1.0 zoom 1.0
linear 1.0 zoom 2.0
repeat 5
My code is on a different computer so it looks kinda odd, but that's essentially what it does.
Last edited by moodykillmar on Wed Jun 14, 2017 8:13 am, edited 1 time in total.

User avatar
DannyGMaster
Regular
Posts: 113
Joined: Fri Sep 02, 2016 11:07 am
Contact:

Re: Procedures?

#2 Post by DannyGMaster »

Probably what you want is to create a transform:

Code: Select all

transform spell_animation:
    xalign .5 #This puts the image at truecenter
    yalign .5
    zoom 2.0 
    linear 1.0 zoom 1.0
    linear 1.0 zoom 2.0
    repeat 5.0
This is not actually a procedure (also called function), it's a block of ATL (Animation and Transformation Language) used by Ren'Py, but once it is coded you can use it as many times as you like just like you would a function.

Code: Select all

    label start:
        "A spell..."

        show spell at spell_animation

        "Another spell..."
        
        show spell2 at spell_animation
More on transform and ATL here: https://www.renpy.org/doc/html/atl.html
The silent voice within one's heart whispers the most profound wisdom.

moodykillmar
Newbie
Posts: 8
Joined: Sun Jun 11, 2017 12:27 pm
Contact:

Re: Procedures?

#3 Post by moodykillmar »

DannyGMaster wrote:Probably what you want is to create a transform:

Code: Select all

transform spell_animation:
    xalign .5 #This puts the image at truecenter
    yalign .5
    zoom 2.0 
    linear 1.0 zoom 1.0
    linear 1.0 zoom 2.0
    repeat 5.0
This is not actually a procedure (also called function), it's a block of ATL (Animation and Transformation Language) used by Ren'Py, but once it is coded you can use it as many times as you like just like you would a function.

Code: Select all

    label start:
        "A spell..."

        show spell at spell_animation

        "Another spell..."
        
        show spell2 at spell_animation
More on transform and ATL here: https://www.renpy.org/doc/html/atl.html
PERFECT! Thanks so much. :D

Post Reply

Who is online

Users browsing this forum: Google [Bot]