Files

> > CS2D > Lua Scripts > Animated Image v2.0
Files overviewCS2D overviewLua Scripts overview

English Animated Image v2.0 >

8 comments6 kb, 482 Downloads

old Animated Image v2.0

MikuAuahDark
User Off Offline

Image Animation by user MikuAuahDark

∗ Description ∗
This LUA allows you to create a animated image that showed frame by frame
This LUA is inspired by this thread: thread us No Animated Avatars

∗ Features ∗
• Easy to use(Only needs 1 function)
• Uses file cs2d Timer Extra function(timerEx) v4.0
• File pattern support(so you only need to rename the file to like the pattern. Gonna explained below)
• Configurable frame speed

∗ To Do List ∗
> Animated PNG support(maybe)

∗ How to Install ∗
Read it at download file page

∗ How to Create animated images ∗
There is a 2 ways to create it.
> With meta.txt(useful for static image setting)
1. Create new folder at gfx folder. This folder will contain your image frame
2. Put all the image at folder that you create before
3. Create new text file called meta.txt and open it
4. Write this in meta.txt
1
2
<File Pattern>
<Image mode> <Speed in miliseconds>
Note: You also need to create the new line
File Pattern - The file pattern(gonna explained below)
Image mode - Image mode(relative to cs2d lua cmd image)
Speed - Frame speed in miliseconds
5. Save
6. On your LUA, put this code somewhere depending on your LUA execution code
1
animated_image_id=imageanimated("gfx/<Folder name that you're create>/",true,nil,<X>,<Y>)
X - X position of the image(pixels)
Y - Y position of the image(pixels)
7. Save, and run your LUA script again to test it
> Without meta.txt(useful for dynamic image setting)
1. Repeat step 1 and step 2 above
2. On your LUA, put this code somewhere depending on your LUA execution code
1
animated_image_id=imageanimated("gfx/<Folder name that you're create>/",false,"<File pattern>",<X>,<Y>,<Mode>,<Player that can see it>,<Speed>)
You already know the parameters. You can see it above
3. Save, and run your LUA script again to test it

∗ File Pattern ∗
File pattern is a string that represent all image frame name. Some Example:
> Your image frame name is gelap_1.png,gelap_2.png,...,gelap_5.png
> Then the File Pattern string should be like this:
1
gelap_%d.png

∗ Reserved Global Variables ∗
> __timerArg*
> timerEx*
> freetimerEx*
> imageanimated
> freeimageanimated
> imageanimatedpos
> tween_animatedmoverot
* - This variable doesn't re-created if already exist

∗ Information ∗
Hooks: 0
Lines: 178
Size: 4068 bytes

∗ Functions ∗
> imageanimated(folder(string),use meta(boolean),file pattern(string),x(number),y(number),mode(number),player(number),frame speed(number))
• Parameters
• > folder - Path to folder that contain all the image frame(with meta.txt if needed)
• > use meta - Use meta.txt file for settings?
• > file pattern - File pattern(explainen above), put nil if you use meta.txt
• > x - X position of the image(pixels)
• > y - Y position of the image(pixels)
• > mode - Image mode(list of image mode: cs2d lua cmd image), put nil if you use meta.txt
• > player - Player that can see the image, put nil if you want to show it for all players
• > frame speed - Frame speed in miliseconds, put nil if you want the default speed(100) or if you use meta.txt
• ∗ Returns: ID of animated image(0 on failture)(number)
• ∗ WARNING: Using cs2d lua cmd freeimage on animated image can cause unexpected berhaviour. Use freeimageanimated instead
> freeimageanimated(animated image id(number))
• Parameters
• > animated image id - ID of the animated image ID that want to be destroyed
• ∗ Returns: none
• ∗ WARNING: Using normal image Ids(created by cs2d lua cmd image) in this function can cause unexpected berhaviour.
• The rest of the function can you found at file •

∗ Notes ∗
1. Your feedbacks, bug reports, suggestions on comments
2. It needs at least timerEx v3.0 or above(Because it's not override the variable, then you can delete the outdated timerEx)
3. Im sorry that there is no image but here is the link of the video: link
4. It needs some delay to show the first frame of the image when the function is called(maybe fixed at v1.1)
5. I put a example image frame at archive

∗ Rules ∗
√ You can use it for your server
√ You can edit it
√ You can upload at another website, say user MikuAuahDark made it
× You can't say this is yours
× You can't upload on another website without put me on credits

∗ Version History ∗
> v2.0
> •
FIXED
Timer doesn't destroyed at roundstart
> •
FIXED
Image animation doesn't destroyed internally at roundstart
> •
CHANGED
Now it shows the first frame without delay
> •
CHANGED
Deleted unused variables
> •
REMOVED
tween_animatedmoverot
> v1.0
> •
ADDED
Initial Release

∗ Another MikuAuahDark Scripts ∗
> file cs2d [UNUSED] Get Player Rank v1.4
> file cs2d Env_Laser v1.0
> file cs2d Weapon Hudtxt v1.0
> file cs2d Improved Badwords v2.0
edited 4×, last 03.11.13 01:05:39 am
Approved by Seekay

Download Download

6 kb, 482 Downloads

Comments

8 comments
To the start Previous 1 Next To the start

Log in!

You need to log in to be able to write comments!Log in

old

Pagyra
User Off Offline

This useful script maybe later the author or someone else universalises it into a separate script module to help us to create and use animation with more easy and convenient way.
I like it!

old

MikuAuahDark
User Off Offline

user brofistmsia has written
that what i want, can i put the image i want? And position and the size?

Do you mean that the position can be set for 1 frame only? sorry, it only allow you to set all position for all frames.

old

brofistmsia
User Off Offline

that what i want, can i put the image i want? And position and the size?
I like it!

old

MikuAuahDark
User Off Offline

user iii has written
does it work with startround, most timer reset there?

Im sorry that it just berhave like normal cs2d lua cmd image, it gonna reset on roundstart. Im forgot to add it at limitations.

EDIT: Gonna fixed at 3PM GMT+7
edited 1×, last 21.09.13 12:16:58 am

old

iii
User Off Offline

should be implemented in cs2d, but there is the risk that the maps become too big with many imgs.
does it work with startround, most timer reset there?
I like it!

old

Deleted
User Off Offline

So how it works?

old

_oops
User Off Offline

Cool, awesome
I like it!

old

Deathliger
User Off Offline

another useful lua by miku
I like it!
edited 1×, last 19.04.17 01:59:42 pm
To the start Previous 1 Next To the start