Utility Script Question

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
dkwroot
Posts: 680
Joined: Thu May 02, 2013 6:56 am
Location: USA
Contact:

Utility Script Question

Post by dkwroot »

I understand Tools, Menus and Embedded scripts, but I've been having a very difficult time finding information regarding utility scripts. My understanding is that utility scripts are loaded as soon as Anime Studio is booted up and they appear to have information about animation channels. My current understanding is that we can declare functions within these utility scripts and then execute those functions from embedded scripts, is this correct?

Has anyone figured out if these utilities can be used to avoid having to use embedded scripts all together? In other words, have the utility check for the currently selected layer type and then interact with tools and menu scripts directly instead of having to hassle with embedded scripts. I would really like to have a custom keyframe channel for my sequencer WITHOUT having to embed on every image layer... :|
User avatar
synthsin75
Posts: 10272
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Utility Script Question

Post by synthsin75 »

Utility scripts are no substitute for layerscripts. Only layerscripts run automatically for each frame, allowing us to change things that are not natively animatable. Utilities are just a place to locate functions that are used a lot and/or by many different scripts. It saves on having, say, the same 20 line function repeated multiple time in the same script, and allows the code to be maintained from a single function. If the next Lua version changes something, you'd only need to update the one function instead of many over several scripts.
dkwroot
Posts: 680
Joined: Thu May 02, 2013 6:56 am
Location: USA
Contact:

Re: Utility Script Question

Post by dkwroot »

Thanks Syn, it's unfortunate that this is the case, but oh well... I really hope they add support for automatic layer script loading in the future.
User avatar
synthsin75
Posts: 10272
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Utility Script Question

Post by synthsin75 »

Automatic layerscript loading? I didn't see you mention that before. Sure you can do that. We can embed scripts by script now, and I have a trick to automatically execute code on startup.
dkwroot
Posts: 680
Joined: Thu May 02, 2013 6:56 am
Location: USA
Contact:

Re: Utility Script Question

Post by dkwroot »

I'm guessing that you put a 'loader' script into a group layer at the top of the pile and then it goes through and embeds scripts to lower layers?
User avatar
synthsin75
Posts: 10272
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Utility Script Question

Post by synthsin75 »

Having to embed a script wouldn't automatically load one on startup, unless you embed a custom startup file, in which case, you'd just embed the scripts you want in that startup file. I use the IsEnabled function of my auto-save tool to execute code on startup, as that function in tools is evaluated on startup, while the same function in menu scripts isn't evaluated until you select the scripts menu.

You just need to know the unique name of the layer you want to embed.
dkwroot
Posts: 680
Joined: Thu May 02, 2013 6:56 am
Location: USA
Contact:

Re: Utility Script Question

Post by dkwroot »

That's really clever! I'll trying doing that and see how it goes. Thanks. :D
Post Reply