Page 1 of 1

Dynamically create ATL

Posted: Thu Aug 18, 2022 5:22 am
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?

Re: Dynamically create ATL

Posted: Thu Aug 18, 2022 5:46 am
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

Re: Dynamically create ATL

Posted: Thu Aug 18, 2022 7:48 am
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?