non-looping animation

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.
Message
Author
User avatar
ISAWHIM
Veteran
Posts: 318
Joined: Sun Nov 06, 2016 5:34 pm
Contact:

non-looping animation

#1 Post by ISAWHIM »

Here is my situation...

I have an animation I am trying to make, which I want to only run once, no looping. However, the only allowed end to an ATL block is "repeat" not "return". As one would expect "return", to run once and then return...

I realize that this assumes all "animations" are "looping animations", but not all are. Actually, most are not.

Sooo... How to do this gracefully, besides adding "pause 999999" at the end, since "pause" without a value, is invalid here, unlike everywhere-else.

Code: Select all

label start:
    image Floor:
        "pose_floor1"
        pause (0.05 * ani_speed)
        "pose_floor2"
        pause (0.05 * ani_speed)
        "pose_floor3"
        pause (99999)
        repeat
Also... The animation does not update with the change of the ani_speed... I have to HIDE and then SHOW it again... Causing an undesired break in a repeating-loop. (Break = unaligned animation frames... since it goes back to frame 1, but it could be on frame 1 or 2, not 3, at the time the old animation is hidden and the new one is displayed.)

EG, In my story, while the animation is playing, the character goes faster and slower, depending on the dialogue. I change the value, before the dialogue is displayed, but the animation keeps playing at the original speed which it was launched with. Even though it clearly is a variable calculated value, it is treating it as a static, "one time calculated", value.

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

Re: non-looping animation

#2 Post by Ocelot »

I want to only run once, no looping.
So... Do not add repeat statement. That is all you need.

Code: Select all

image foo:
    'bar1.png'
    0.5
    'bar2.png'
    0.4
    'bar3.png'
< < insert Rick Cook quote here > >

User avatar
ISAWHIM
Veteran
Posts: 318
Joined: Sun Nov 06, 2016 5:34 pm
Contact:

Re: non-looping animation

#3 Post by ISAWHIM »

Ocelot wrote:
I want to only run once, no looping.
So... Do not add repeat statement. That is all you need.

Code: Select all

image foo:
    'bar1.png'
    0.5
    'bar2.png'
    0.4
    'bar3.png'
Hmm... Most obvious... Thanks! (Another assumption required or incorrectly implied by the help documentation.)

Sorry, I was going off every example, and for ATL, it seemed "required", as it was in every example on the page and says "The syntax for an image statement with ATL block is:"

Code: Select all

atl_something ::= "someName"... ...
    stuff ... ...
    atl_block
Nearly every example shows like this...

Code: Select all

someName:
    AnimationContentCode
    repeat
That tends to imply that it "must end the block" and using "repeat" as the termination. Honestly, that code-form above the actual used example, is just adding confusion to the matter. Especially since it is never written that way, nor does it actually, logically imply anything functional to the actual use. Not as much as saying it is an ATL block, when it simply looks like all other blocks of code.

User avatar
ISAWHIM
Veteran
Posts: 318
Joined: Sun Nov 06, 2016 5:34 pm
Contact:

Re: non-looping animation

#4 Post by ISAWHIM »

Now, how do I get it to actively display with the correct speeds, as the delays change?

Since they only seem to be calculated once, when the images are loaded, and not actively calculated as they are displayed.

I have a feeling this is going to be complex...

Out of my head, I can only think to remember each frames value, then reload it with the new speed, from the next frame after the last frame displayed. Would be more functional with a dynamic image-name, relative to the frame-number. (But I haven't learned how to do that yet. Nor am I sure it will even work here, since this is not loading images the same way.)

Assume I have 20 frames, 1-20

This is how I would write it in normal "basic" languages. (Below is not actual code. I don't think.)

frame += 1
if frame > 20 then frame = 1
"picture[frame].jpg"
repeat

or

for x = 1 to 20
"picture[x].jpg"
next x

{Assumes that [frame] will be replaced with the value, as a string, for the name of the image loaded... picture1.jpg, picture2.jpg

Then, if I reload it, and it was on frame 8... now it would reload at frame 9, with the new speed... right?

User avatar
ISAWHIM
Veteran
Posts: 318
Joined: Sun Nov 06, 2016 5:34 pm
Contact:

Re: non-looping animation

#5 Post by ISAWHIM »

Again, another area where code just doesn't seem to work as expected, or as examples portray...

Code: Select all

label start:
    image TestImage:
        $ count = 0
        while count < 10:
            "floor[count]"
            pause 0.5
            $ count +=1
        repeat
Seems there is no "for loops", which leaves us using "while loops"... I can deal with that... does not add too much complexity.

However, they don't seem to work in these blocks, as the examples show on this page...
https://www.renpy.org/doc/html/conditio ... -statement

Expected operation...
$ count = 0 <- First image is "floor0.jpg"
while count < 10: <- continues to loop while not 10... 0-9
"floor[count]" <- Tells it to load image "floor0.xxx", "floor1.xxx" etc...
$ count +=1 <- increments number before looping
repeat <- (Obviously, repeat until hidden. 0,1,2,3,......0,1,2,3.... etc)

Where it fails...
$ count = 0 <- here

Reason...
"expected comma or end of line not found"

Last time I checked, no comma was needed, or end-of-line, for a variable value...

User avatar
indoneko
Miko-Class Veteran
Posts: 528
Joined: Sat Sep 03, 2016 4:00 am
Contact:

Re: non-looping animation

#6 Post by indoneko »

Can we actually use conditional statement inside ATL images?
Perhaps you need a python function for it...
My avatar is courtesy of Mellanthe

philat
Eileen-Class Veteran
Posts: 1926
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: non-looping animation

#7 Post by philat »

Well, because conditional statements are renpy statements and not ATL statements...? Which seems pretty clear from the examples in the conditional statement doc and the ATL doc...?

User avatar
ISAWHIM
Veteran
Posts: 318
Joined: Sun Nov 06, 2016 5:34 pm
Contact:

Re: non-looping animation

#8 Post by ISAWHIM »

philat wrote:Well, because conditional statements are renpy statements and not ATL statements...? Which seems pretty clear from the examples in the conditional statement doc and the ATL doc...?
No, it's code... I expect it to function as code, within renpy, wherever it exists, as code. In a statement, in a conditional, in a choice, in other blocks of code...
Ren'Py Script Statements
ATL Code can be included as part of three Ren'Py script statements.
https://www.renpy.org/doc/html/atl.html
Image Statement With ATL Block
The second way to use ATL is as part of an image statement with ATL block. This binds an image name to the given transform. As there's no way to supply parameters to this transform, it's only useful if the transform defines an animation. The syntax for an image statement with ATL block is:
I am not "supplying parameters to it"...
I am using it to "define an animation"...

Which, naturally would include "code" to "define the animation"... Such as sequences, flow, direction, interactions, times, delays.

This is a fourth set of "pseudo-code" that isn't apparently code. One with real specific things that can be listed, and work within it, which are easily confused with the actual "code/script", designated as "working within blocks", which describe themselves as code-blocks.

This is why I get confused... So, where does the actual code have to go, if it can't be used in these code-blocks that don't accept some code, but accept some code, just not the code I want to use, which is renpy code?

So, essentially, I have to build my own functions that do exactly like ATL, using ATL, to get renpy's code to work, with ATL, doing what it should do within ATL code-blocks, which is a whole other language, that uses renpy-like language but not renpy code, to function. Gotcha... I can deal with that, now that I realize it isn't renpy code and doesn't allow renpy code inside of those blocks, only that other set of code/script. Which looks exactly like renpy code/script, but isn't.

It saves me time... That's all that matters... and it runs smoother than what I had, even if I have to code each frame individually.

Still looking for a way to automate this, so it is, well, useful as code, or as a function.

philat
Eileen-Class Veteran
Posts: 1926
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: non-looping animation

#9 Post by philat »

Dude. You do realize you're being an ass, right?

User avatar
ISAWHIM
Veteran
Posts: 318
Joined: Sun Nov 06, 2016 5:34 pm
Contact:

Re: non-looping animation

#10 Post by ISAWHIM »

philat wrote:Dude. You do realize you're being an ass, right?
By pointing-out facts or by being humanly confused by the unclear statements, and seeking clarity?

I am highly sarcastic... Perhaps too-much at times. I will try to tone it down a notch if my sarcasm is too ass-like. (That isn't a first time that I heard that. However, frustration of things not working as expected, or at all, with no knowledge of what to actually search for, is kind-of why people come to forums. I don't expect resolutions to all my problems... I just want to know when it is time to cut my losses and find other methods. Like I did here.)

User avatar
indoneko
Miko-Class Veteran
Posts: 528
Joined: Sat Sep 03, 2016 4:00 am
Contact:

Re: non-looping animation

#11 Post by indoneko »

Please... don't go off topic, okay? :lol:

If you just want to repeat a certain block of animation for n times, you don't really have to put conditional statement in your atl images. Put an integer after the repeat statement instead. For example :

repeat 3
My avatar is courtesy of Mellanthe

User avatar
ISAWHIM
Veteran
Posts: 318
Joined: Sun Nov 06, 2016 5:34 pm
Contact:

Re: non-looping animation

#12 Post by ISAWHIM »

indoneko wrote:Please... don't go off topic, okay? :lol:

If you just want to repeat a certain block of animation for n times, you don't really have to put conditional statement in your atl images. Put an integer after the repeat statement instead. For example :

repeat 3
See, another undocumented answer... I didn't even know that was a possibility. (Does not mention anywhere on the ATL page, about "repeat" being optional or having parameters.)

However, the second question was trying to resolve the issue with using dynamic image-names, instead of having to type-out 1000 image-names from 1-1000, with 1000 individual "pause (xxx)" statements following the image-names. (The looping was the first issue.)

He made it clear... renpy-code is not allowed within a renpy ATL code-block. (I can see that now that it was stated. Now I see it as what it is... script, not code.)

Prior to finding the ATL thing... I was doing this...

Code: Select all

show image0
pause(0.10)
hide image0
show image1
pause(0.10)
hide image1
show image2
pause(0.10)
...
...
show image999
pause(0.10)
Because that is how it shows you to display images... :P

However, there is a funky lag with loading and unloading (showing/hiding). The ATL script thing was cleaner and faster with large PNGs. (The other ATL script... I see that this too is the "third" form of ATL. Tells you that on the ATL page, but not where it tells you about loading images.)

I promise, I am giving this EVERY honest effort to succeed, now that I am this far into it.

User avatar
indoneko
Miko-Class Veteran
Posts: 528
Joined: Sat Sep 03, 2016 4:00 am
Contact:

Re: non-looping animation

#13 Post by indoneko »

Actually, this is already mentioned in the doc. I didn't realize it too at first.
The repeat statement is a simple statement that causes the block containing it to resume
execution from the beginning. If the expression is present, then it is evaluated to give an
integer number of times the block will execute. (So a block ending with "repeat 2" will execute
at most twice.)
As for creating an ATL image which consist of 1000 images with unique/individual delays, I'm not really sure if there's any way to automate the process... :roll:
My avatar is courtesy of Mellanthe

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3808
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: non-looping animation

#14 Post by Imperf3kt »

It is not in the online documentation, but it is in the renpy tutorial.

Where are you looking for documentation?

If you want a large number of frames, use a video instead.
Make your images, name them 0000.png, 0001.png, etc.

Load them as a sequence with virtualdub, output as AVI, then compress and convert to a format renpy accepts
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: non-looping animation

#15 Post by Divona »

Ren'Py code kinda allows in ATL block with Function Statement. Here is a hacky thing I did to automate the frame of images in ATL:

Code: Select all

init python:

    def ResetFrameCount():
        global currentFrame
        currentFrame = -1

    def FrameCountUp(trans, st, at):
        global currentFrame
        currentFrame += 1

define animation_speed = 0.10

image anime:
    function FrameCountUp
    DynamicImage("images/image[currentFrame].png")
    pause animation_speed
    repeat 48  #number of frames to display

label start:

    $ ResetFrameCount()
    show anime

    "Play animation."
This mean the name of the image file has to be "image0.png", "image1.png", "image2.png" and so on. DynamicImage will deal with adding those number to file path, while FrameCountUp module would add number up as it being called by "function" in ATL block. Use ResetFrameCount() before show animation image, to reset the count to zero. This method will not loop the animation but only show as many frames as specify in "repeat" within ATL block.
Completed:
Image

Post Reply

Who is online

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