Dynamically create ATL

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
nananame
Regular
Posts: 72
Joined: Fri Oct 13, 2017 1:40 pm
Contact:

Dynamically create ATL

#1 Post by nananame »

I will have quite a bit of simple animations going on in the game. Something I would usually use the ATL blocks for.
Example:

Code: Select all

image man1:
    "man1_1"
    0.2
    "man1_2"
    0.2
    "man1_3"
    0.2
    repeat
Problem is, there will be A LOT of these. So I want to avoid writing the ATL block for each and every one and would love to define the block but have the image be an argument I pass in. Since this doesn't work with ATL, I though about using a function:

Code: Select all

    def animationsfunction(image,x,y):
        while True:
            renpy.show (image + '_1',at_list=[Position(xanchor = 1, yanchor = 1,xpos=x,ypos=y)])
            renpy.pause(0.2)
            renpy.hide(image + "_1")
            renpy.show (image + "_2",at_list=[Position(xanchor = 1, yanchor = 1,xpos=x,ypos=y)])
            renpy.pause(0.2)
            renpy.hide(image + "_2")
            renpy.show (image + "_3",at_list=[Position(xanchor = 1, yanchor = 1,xpos=x,ypos=y)])
            renpy.pause(0.2)
            renpy.hide(image + "_3")
While this works, I am not sure about performance AND it won't work when I need to use several at the same time (presumably because the function is already running).
So calling:
$animationsfunction("image1",50,50)
$animationsfunction("image2",150,150)
will only display image1.

Is there a better way? Either by improving on this function so it can run multiple times, or by using a better renpy alternative?

User avatar
m_from_space
Miko-Class Veteran
Posts: 957
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Dynamically create ATL

#2 Post by m_from_space »

Okay, please don't create a "while True" loop ever. :D

I guess this might help you out: https://www.renpy.org/doc/html/displaya ... isplayable

nananame
Regular
Posts: 72
Joined: Fri Oct 13, 2017 1:40 pm
Contact:

Re: Dynamically create ATL

#3 Post by nananame »

lol, yes, agreed. This was for testing purposes only.

As for DynamicDisplayable - had a look but not sure how that would work.
The example shows it as being defined--> image name = DynamicDisplayable(function,argument). Meaning I would still need to define each image. Or did I get something wrong there?

What I need is something where I can supply the argument on the fly.
Can you provide an example if that could somehow be used with the DynamicDisplayable?

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Yone28