Introduction

Smith Micro's Anime Studio Pro is a complete animation system for creating 2D cartoons. Anime Studio's toolbar and script menu are implemented in the Lua programming language, as scripting "plug-ins". This document describes the programming interface available to Anime Studio plug-in scripts.

Anime Studio's scripting interface is divided into three "modules":

LM is the lowest-level module, and includes very basic objects like vectors and colors.

LM.GUI is a user interface module that is built on top of Anime Studio's cross-platform user interface library. Scripts can use the user interface widgets in this module to build dialog boxes, and to set up custom interfaces for toolbar buttons.

MOHO is the module that is a direct interface into Anime Studio itself. The objects and functions in the MOHO module allow scripts to create and manipulate Anime Studio layers, vector artwork, bone systems, and more.

Creating objects: When a script creates new objects in Anime Studio., it will most often not create them directly, but call a function to do the job. For example, a script never creates a new layer object directly, but tells Anime Studio to insert a new layer:

 
-- *** Ask Anime Studio to create a new vector layer ***
local layer = moho:CreateNewLayer(MOHO.LT_VECTOR)
 

The only cases where a script will directly create a new object is for very simple object types, like points, vectors, and colors. For example, to create a new 2D vector object, a script might do the following:

 
-- *** Create a new local variable ***
local vec = LM.Vector2:new_local()
 
-- *** Create a new global variable ***
gVec = LM.Vector2:new()
 

Script Conventions

Posted in Introduction

When creating a new script, it is important that the script have a unique name. Otherwise, two scripts with the same name would interfere with one another, and most likely neither one would work correctly.

The convention that Anime Studio uses is for scripts to be named with a prefix representing the creator of the script. For example, the Add Point tool (that comes included with moho) is named "LM_AddPoint", the "LM" standing for "Lost Marble".

If you create your own scripts, please give them a prefix that represents yourself, or your company. Do not use the prefix "LM". Even if you created a script called "LM_Fireworks" that doesn't exist in Anime Studio Pro, there's no guarantee that Smith Micro will never include a fireworks script. But if your name is Joe Blow and you name your script "JB_Fireworks", then both your script and Smith Micro's script can co-exist without interference.

Script Installation

Posted in Introduction

There are two main categories of scripts in Anime Studio, tool and menu scripts, and each one must be installed in a slightly different way to work with Moho.

Menu scripts are easy - inside the Anime Studio program folder is a sub-folder called "scripts". Inside this is another folder called "menu". If you place a menu script in that folder, it will automatically appear in the Scripts menu when you start up Moho. This folder is further subdivided into different categories that appear as sub-menus in Anime Studio, and you are welcome to install your menu script in whichever category makes the most sense.

Tool scripts are a little more complicated. Look at the "scripts" folder in the Anime Studio program folder again. Notice the "tool" sub-folder. All tool scripts must be placed in this folder. If you create a new tool script and put it in that folder, it will appear at the bottom of the Anime Studio toolbar in a new tool category labeled "Other". This is the simplest way to install a new tool script. However, if you want to control where exactly your new tool should appear, look at the file called "_tool_list.txt" in the same folder. This is a text file that you can edit with a basic text editor like Notepad. In this file, you'll see that tools are organized into groups, and arranged in a logical order. You are welcome to modify your copy of this file to install your own tool scripts wherever on the toolbar you wish.