How can I write a script for Anime Studio Pro 7?

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
PRIMAL MORON
Posts: 43
Joined: Sun Oct 18, 2009 3:22 pm

How can I write a script for Anime Studio Pro 7?

Post by PRIMAL MORON »

I was thinking of starting lua programming so I could make my anime studio program more powerful. But I need some resources for using lua specifically for ASP 7. I've been using the program for quite some time. Since the late moho/early AS 5.5 time, I've felt could contribute something. I would love to hear from of the scripting legends such as Heyvern about where I can learn to build my own scripts for anime studio. I feel it to be an honor to learn from the users here, any info on this is appreciated!

That's all for now.
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

The first step would be learn the basics of lua. Read up on it, study how it works. There is a ton of fantastic and useful resources for learning Lua on the internet.

I use this one probably 99% of the time. Mostly because it's formated nicely and very easy to read and navigate and also it usually comes up first in a google search:
http://lua-users.org/wiki/

If you just do a google search for anything "lua" you can find even more stuff. Another thing I do all the time is to google something with lua. For example "lua math", or recently I googled "lua string" or if I know what a lua function is but can't remember exactly how it works; "lua string.sub" or "lua string.find".

There are books available for purchase, however a lot of that info is free on the internet. Some people prefer an actual book. Many of the sites with lua info have TONS of example code.

--------------------

Next you need the references that are specific to Anime Studio:

The script references below show you how to access and manipulate objects and properties in the AS file.

Get the scripting reference HTML files in the download link in the first post here:
viewtopic.php?t=1031

This will cover everything up to about v5. It is a fairly well organized set of html pages with a navigation frame. It doesn't contain sample code snippets and sometimes what is there isn't "exactly" how it should be used in the code. That is why reading EXISTING scripts in AS is a must for learning how to use lua.

Next get the most recent reference files for 6.0 and 6.1 here:

viewtopic.php?t=13513
These files are just text files and not done in the same way as the reference files, however everything is there and is pretty clear how to use it (once you are familiar with lua and AS scripting).

-----------------

You need to understand what is "Anime Studio" and what is "lua". Lua is based very strongly on "tables" or "arrays". So Anime Studio objects and items that can be manipulated exist in the interface as references to tables of items. Like bone lists, point lists, layers etc etc. You access a bone by referencing a "bone in a skeleton in a layer". You use the script reference that is specific to AS to retrieve the items THEN you use lua to process the properties of those items. The "hooks" to manipulate those things have to be put there by the developer. In AS 6/7 Mike put in a bunch of new items we can access that we couldn't manipulate before. One example added in v6 was key frame interpolation. Before version 6 you could not read the interpolation method at all for a key frame. You could set it but not read it. NOW we can READ the key frame interpolation.

Lua is very very very very powerful and EXTREMELY fast. It can do some amazing things with a lot of data VERY QUICKLY. It has the ability to open, read, create, edit external files and it can also use the OS of the computer to even launch other applications and access files and folders.

Before you go nuts trying to create some crazy wild script, look at the existing tools and menu scripts included in AS. I would say a huge portion of everything I learned was based on looking at the tools and scripts that the base Anime Studio uses. Use those to learn from and get started. If you want to update a tool use the original as a reference.

Lua is fairly easy to learn. It is as easy if not easier to learn than Javascript or Actionscript. I was pretty good with both JS and AS before attempting to learn lua and I learned it pretty fast. I am not the scripting guru everyone seems to think I am. I've see people create AMAZINGLY COOL scripts in a fraction of the time I could do it and doing things better than I would.

------------------------
Personal Tip:

Another thing to think about when creating scripts is that you can code for a specific project. Suppose you have a large project that requires a lot of repetition. Create a script that does that for you even if is just a one off project it can save hours and hours of time. I did that a few years back for a huge gigantic project with dozens of identically formatted files with images and switch layers. I created a series of fairly simple scripts that automated hours of drudgery. It took me some time to create the scripts but the time savings was enormous and completely prevented "user error" when doing the same repetitive tasks over and over. I reduced 1 to 2 hours of work per file down to just a few minutes.

-vern
Post Reply