Animation control

Any information about the fun attribute is given here.
Previous topicNext topic
User avatar
Lobby
Inhabitant of a Supercluster
Reactions:
Posts: 3771
Joined: 26 Oct 2008, 10:34
Plugins: Showcase Store

Animation control

Post by Lobby »

An often requested feature is animation control using fun. It's possible in recent versions and looks like that :json

Code: Select all

[
  {
    "id": "$anim_test_control00",
    "type": "terrain",
    "width":1,
    "height":1,
    "template":"$template_ground",
    "frames":[{"x":416,"y":96,"w":32,"h":16}],
    "animation":[
      {"id":"$animationfan00","x":-16,"y":-48}  // Animation slot 0
    ],
    "on click fun":{
      "condition":{"type":"animation running"},   // Is animation in slot 0 running?
      "action":{"type":"animation pause"},        // Pause it
      "else action":{"type":"animation resume"}   // Resume it
    }
  }
]
(this plugin doesn't need external graphics, you might just put it in a json file in your plugins folder)
Show
animation running
This condition is true if the animation slot specified by "level" (0 by default) is running right now. If "frame" is provided it will also check for the current visible frame to be the same as "frame".
Show
animation pause
This action pauses the animation slot "level" (0 by default). Additionally sets the frame to "frame" if specified.
Show
animation resume
This action resumes the animation slot "level" (0 by default). Additionally sets the frame to "frame" if specified.
:mine
User avatar
Bearbear76
Inhabitant of a Multiverse
Reactions:
Posts: 5711
Joined: 10 Feb 2017, 12:53
Location: L2 cache
Plugins: Showcase Store

Plugin Creator

Platform

Re: Animation control

Post by Bearbear76 »

Is it possible to dictate other animations?
For example

Code: Select all

"condition":{"type":"animation running", "id":"animation ID"},
Just my opinion
retired
User avatar
JustAnyone
Honorary Contributor
Reactions:
Posts: 3685
Joined: 23 Jul 2017, 10:45
Location: Easter Island
Plugins: Showcase Store

Platform

Re: Animation control

Post by JustAnyone »

Yes, using sloths slots.
"level":1 will use 2nd animation which is defined in building "animation".
:pickle:
User avatar
Imran M
Inhabitant of a Country
Reactions:
Posts: 843
Joined: 24 Oct 2018, 11:41
Plugins: Showcase Store

Plugin Creator

Platform

Re: Animation control

Post by Imran M »

So, you can make this stop and start an animation with this type of fun?
I just love the DOPE-amine you get after completing a plugin!
User avatar
Lobby
Inhabitant of a Supercluster
Reactions:
Posts: 3771
Joined: 26 Oct 2008, 10:34
Plugins: Showcase Store

Re: Animation control

Post by Lobby »

Yes, that's what it's for.
User avatar
Imran M
Inhabitant of a Country
Reactions:
Posts: 843
Joined: 24 Oct 2018, 11:41
Plugins: Showcase Store

Plugin Creator

Platform

Re: Animation control

Post by Imran M »

Hey, could I get some help? I followed it to a T, but it won't change when I click on it.

Code: Select all    Reset

[{ "id":"2x2HD SE", "type":"animation", "frames":[{ "bmp":"Hangar Doors.png", "x":0, "y":0, "w":16, "count":1, "count y":15, "count x":0 }] },{ "id":"2x2HD SW", "type":"animation", "frames":[{ "bmp":"Hangar Doors.png", "x":16, "y":0, "w":16, "count":1, "count y":0, "count x":0 }] },{ "id":"2x2 Hangar SE", …//same "frames":[{ "bmp":"2x2 Hangar.png", "x":0, "y":0, "w":64, "count":1 }], …//Same "animation":[{ "id":"2x2HD SE", "x":36, "y":-6 }], "on click fun":{ "condition":{"type":"animation running"}, "action":{"type":"animation pause"}, "else action":{"type":"animation resume"} } },{ "id":"2x2 Hangar SW", … //Code that doesn't really matter "frames":[{ "bmp":"2x2 Hangar.png", "x":64, "y":0, "w":64, "count":1 }], …//Same "animation":[{ "id":"2x2HD SW", "x":12, "y":-6 }], "on click fun":{ "condition":{"type":"animation running"}, "action":{"type":"animation pause"}, "else action":{"type":"animation resume"} } }]
JSON checker
Check
2x2 Hangar.png
Hangar Doors.png
Or:
Hangar that don't work.zip
You do not have the required permissions to view the files attached to this post.
I just love the DOPE-amine you get after completing a plugin!
User avatar
CommanderABab
AB
Reactions:
Posts: 11311
Joined: 07 Jun 2016, 19:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Animation control

Post by CommanderABab »

Imran M wrote: 23 Jan 2021, 18:55 Hey, could I get some help? I followed it to a T, but it won't change when I click on it.

Code: Select all

[{
    "id":"2x2HD SE",
    "type":"animation",
    "frames":[{
        "bmp":"Hangar Doors.png",
        "x":0,
        "y":0,
        "w":16,
        "count":1,
        "count y":15,
        "count x":0
    }]
},{
    "id":"2x2HD SW",
    "type":"animation",
    "frames":[{
        "bmp":"Hangar Doors.png",
        "x":16,
        "y":0,
        "w":16,
        "count":1,
        "count y":0,
        "count x":0
    }]
},{
    "id":"2x2 Hangar SE",
    …//same
    "frames":[{
        "bmp":"2x2 Hangar.png",
        "x":0,
        "y":0,
        "w":64,
        "count":1
    }],
    …//Same
    "animation":[{
        "id":"2x2HD SE",
        "x":36,
        "y":-6
    }],
    "on click fun":{
        "condition":{"type":"animation running"},
        "action":{"type":"animation pause"},
        "else action":{"type":"animation resume"}
    }
},{
    "id":"2x2 Hangar SW",
    … //Code that doesn't really matter
    "frames":[{
        "bmp":"2x2 Hangar.png",
        "x":64,
        "y":0,
        "w":64,
        "count":1
    }],
    …//Same
    "animation":[{
        "id":"2x2HD SW",
        "x":12,
        "y":-6
    }],
    "on click fun":{
        "condition":{"type":"animation running"},
        "action":{"type":"animation pause"},
        "else action":{"type":"animation resume"}
    }
}]
2x2 Hangar.png
Hangar Doors.png
Or:
Hangar that don't work.zip
my avatar:
User avatar
CommanderABab
AB
Reactions:
Posts: 11311
Joined: 07 Jun 2016, 19:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Animation control

Post by CommanderABab »

In your animation frames definition, what's this section supposed to do?:

Code: Select all

"count":1,
        "count y":15,
        "count x":0
I've never seen anything with a count y or count x.
Maybe your animation doesn't seem to move because it just has a count of 1 which would be a static image.
my avatar:
User avatar
Imran M
Inhabitant of a Country
Reactions:
Posts: 843
Joined: 24 Oct 2018, 11:41
Plugins: Showcase Store

Plugin Creator

Platform

Re: Animation control

Post by Imran M »

CommanderABab wrote: 24 Jan 2021, 11:22 In your animation frames definition, what's this section supposed to do?:

Code: Select all

	"count":1,
        "count y":15,
        "count x":0
I've never seen anything with a count y or count x.
Maybe your animation doesn't seem to move because it just has a count of 1 which would be a static image.
I thought you needed the count x/y to give a sort of point to the anim, then you can specify where you want it?
I think you're right, I wanted it be sort of like a door, and when you click on it, it turns off/disappears. But, it appears that it doesn't remove the animation, it stops it. Do you have anything like a "turn off animation" action?

I could just create 2 more frames (one closed and one opened for each rotation) and just get it to switch frames, kind of like how Lobby did it with that button. However, that'll require more plugin space.
I just love the DOPE-amine you get after completing a plugin!
User avatar
CommanderABab
AB
Reactions:
Posts: 11311
Joined: 07 Jun 2016, 19:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Animation control

Post by CommanderABab »

It would be:

Code: Select all

"handle y": 15,
"handle x":0
:)
my avatar:
User avatar
rencute28mr
Villager
Reactions:
Posts: 9
Joined: 21 Feb 2025, 00:46

Re: Animation control

Post by rencute28mr »

Tokyo.gif
can you help me? I need the code to make an animation of those building. the building have 10 frame, it's start with frame 1 and Ended on frame 10. like you place the closed frame then when you click it, the building appears from below.
Previous topicNext topic