Hello everyone!
Today we're going to talk about what are scripts in Moho, and how to install them.
They can be of three types:
Tool Panel scripts (tools and buttons).
Menu-scripts.
Layer-scripts.
What are scripts?
The word "script" means "scenario".
A person writes the scenario, and the program reads and executes it.
People who write scripts, often share them on the Internet,
where anyone can download and install them.
There are three ways to install scripts in Moho.
In this lesson we're going to discuss the easiest yet the most convenient one - installation via the content folder.
Perhaps, it's worth saying a few words about what is the Content Folder.
It's a special folder on your hard drive that Moho interacts with to get scripts, templates, and other files.
It's very convenient that all versions of Moho use the same Content Folder.
That is, scripts installed with the way we're discussing here, will be equally available for Moho x32 and x64,
and for the future Moho releases as well.
If you're not using the Content Folder yet, you should create it first.
To do that, let's go to Edit > Preferences, and click the Custom Content Folder button.
Select a folder on your hard drive, and Moho will automatically create all what's needed.
As you can see, there is this Moho Pro folder inside, as well as some others.
We don't need the most of them for now, the only folder that we need now is the "scripts" one.
Let's get ourselves familiar with the Tool Panel scripts and discuss how to install them.
The Tool Panel has tools and buttons.
The difference between them is that a tool is something that you turn on and work with,
while a button just performs a single action when clicked.
For example, the Recolor Shape script is a tool.
When you click the icon, it becomes active, the panel with its controls shows up, and also the cursor changes.
You can work with this tool by clicking on shapes and changing their style.
Now the Hide Points script is a button.
If you click it, all the points will become hidden, except the selected ones.
It is useful when you have too many points on the screen and need to work with only some of them.
Click the button again, and all points will be shown again.
So, a button just performs a single action, which, however, can be pretty complicated. For example, the Insert Text.
This script also performs a single action,
but that action includes opening the dialog box, setting up the text parameters, and creating a new layer.
From the program's point of view, it's only a single operation that, however, includes several stages.
Now I will remove all the custom scripts in my Moho, and show you how to install them.
As you see now, my Tool Panel contains only the default tools, which, as a matter of fact, are also scripts.
Let's open the Content Folder using the FIle > Open Custom Content Folder command.
The "scripts/tool" folder is responsible for the Tool Panel.
Let's drag the Recolor Shape files to that folder - the .lua file, the icon, and the cursor…
Now let's do the same for the Hide Points files - the script file, and the icon...
I must say that Moho reads and compiles all the scripts at the moment the program starts.
Therefore, after you install new scripts, you need to either restart Moho or make it re-read all scripts.
That can be done by the hotkey of Ctrl+Alt+Shift+L.
Let's press that combination of keys, everything is reloading, and as you may see, the new tools are now displayed in the panel, at the very bottom of it.
To move the new script to a particular group, we need to go to the Edit > Preferences > Tool Layout menu.
Check this box if it is unchecked, locate our new scripts at the bottom, and by pressing the Move Up and Move Down buttons, move the Recolor Shape, for example, to the Fill group,
and for the Hide Points I will create a new group and move it there.
Save the settings, and now the tools are located where they should be!
Menu scripts are essentially the same as the buttons.
They perform a single operation, and can be installed either to the Tool Panel, or to the Scripts menu.
Usually, if you need to use the script often, you should install it into the Tool Panel,
otherwise it is better to put it to the menu.
For our example, I'll take the same Hide Points script, remove it from the Tool Panel, and install to the menu.
First, I'll remove the files of the script and the icon from the "tool" folder, where I put them before.
Select the file, and delete them...
The installation to the menu is simple - take the .lua file and put it into the "menu" sub-folder of the same "scripts" folder.
As you may see, there are several sub-folders inside, which are the categories of the Scripts menu.
Let's create our own folder here, and name it "Points".
Move our file into that folder, and that's it!
Press Ctrl+Alt+Shift+L, and verify that the script was removed from the Tool Panels, and is available now in the menu of Scripts > Points > Hide Points.
Before the invention of the Content Folder, scripts needed to be installed directly into the program's folder.
That method is still supported nowadays, but it is obsolete and you should not use it.
The Content Folder's tools take priority over the Moho folder's tools.
Therefore, never copy scripts from the Moho folder into the Content Folder.
Otherwise, if you later update Moho to a newer version, the old scripts from the Content Folder will override the new ones.
There's also the Scripts > Install Script command,
but it requires the files to be enclosed in a very strict structure of folders.
So, if you downloaded an archive and inside that archive you see a folder that has a sub-folder of "tool" or "menu"
(and maybe others as well), then it's meant to be installed via the Install Script command.
Such an archive can even contain not just one, but several scripts at once.
Unzip the folder from the archive, run the command, and select the unzipped folder.
Moho will take care of the rest - copy the files to the Content Folder, and refresh the interface.
It is very convenient, but only when the files are already pre-packed into the structure.
The layer-script's installation is as easy as pie.
For example, let's take the Rotating Bone script.
This script is intended for embedding into a bone layer.
It searches for the bones named "Wheel" and automatically rotates them according to the parent bone's translation.
This bone is the parent, and these bones are named "Wheel", and the wheels are binded to them.
Now let's open the bone layer's properties.
In the first tab, there is a checkbox for Embedded script file,
let's click it, and select the script file.
Click OK, and now we see that it works!
There is an important note.
Embedded scripts are external files, and they are not stored within the Moho's project file.
The project only keeps the path to the script on your hard drive.
So be careful, if you move or delete the script file, it will stop working in the layer.
That's all! Bye everyone!
Không có nhận xét nào:
Đăng nhận xét