Embedded Scripts

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

Moderators: Víctor Paredes, Belgarath, slowtiger

mwdf
Posts: 4
Joined: Sun Feb 12, 2006 4:52 pm
Location: WI, USA
Contact:

Post by mwdf »

CTRL-F5 doesn't seem to reload the embedded layer scripts.

Is there a faster and/or easier way to do it than deselecting the "Embedded script file" checkbox, and then locating your script again?
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

Not that I've found. It is a bit of a pain in the arse, ain't it? Don't recall if anyone actually asked LM to fix that. Unless there is a way, but I'm not aware of one.
User avatar
bupaje
Posts: 1175
Joined: Fri Nov 12, 2004 5:44 pm
Location: California
Contact:

Post by bupaje »

Dumb question maybe but I remember that script for fixing broken image associations -could that be modified to somehow 'find' the script again?
[url=http://burtabreu.animationblogspot.com:2gityfdw]My AnimationBlogSpot[/url:2gityfdw]
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

Might be, but I'm not sure. Theres a few things that arent documented yet (like the new function that makes the paintbucket work), but I dunno. It probably wouldn't save a whole lot of time, unless you made a button tool to reload them. If there was access in Lua to what you needed, I'd do that, as usual I could use it too.
User avatar
Rai López
Posts: 2228
Joined: Sun Aug 08, 2004 1:41 pm
Location: Spain
Contact:

Post by Rai López »

mwdf wrote:CTRL-F5 doesn't seem to reload the embedded layer scripts.
I use this little trick:

- I've any embedded script applied in any Moho layer.
- I go to SciTE (of course) and modify any applied embedded script.
- Return to Moho and press Ctrl+F5.
- I Make any change in Moho (move a layer, a bone, point... any) and press Ctrl+Z to UNDO it.
- The embedded scripts are reloaded :)

It seems like a little pain but it have saved a lot of time to me, try it!
alongz
Posts: 21
Joined: Mon Jun 19, 2006 3:13 pm
Location: malaysia

beginner in scripting

Post by alongz »

hi im a beginner in moho software. i just want to ask how to embed a script in a Moho layer work and how to create the *.lua file?can someone please teach me...tq
i like an animation..
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Re: beginner in scripting

Post by heyvern »

alongz wrote:hi im a beginner in moho software. i just want to ask how to embed a script in a Moho layer work and how to create the *.lua file?can someone please teach me...tq
This link:

http://www.lua.org/pil/

Along with the Moho Scripting reference available in the scripting forum:

http://www.lostmarble.com/forum/viewtopic.php?t=1031

... is what I used to get started. LUA is about as complex to learn as Javascript. If you have no programming experience at all... it may be a bit of a learning curve for you.

I already had some experience with JS and was able to use that knowledge to help learn LUA.

I also used the existing scripts that come with Moho and that others wrote to learn LUA. Going through a simple tool or menu script VERY CAREFULLY... looking at each line and trying to understand what it is doing from the results of a working script is very very helpful.

If you can eventually "work out" what a script is doing just by reading the code this can lead to a better understanding.

It would be near to impossible to "teach" you LUA from scratch through the forum. If you get a basic understanding of programming in LUA from many free resources on the web and possibly books on the subject and then need specific help on certain areas... hopefully someone here may be able to point you in the right direction.

-Vern
User avatar
Fazek
Posts: 246
Joined: Thu Apr 13, 2006 1:37 pm
Location: Hungary
Contact:

Post by Fazek »

Make a copy of a short .lua file in the scripts/tool folder of your Moho directory, changing the lm_ beginning of the filename to your favourite two letters (try to choose a unique letter pair, hv_, sf_, fa_, cc_, etc. are already used by others) . You can use these letters to identify all of your scripts in the future. The copied program will appear as a button on the tool window in Moho. With a graphic program, you can create an icon too, with the same name and .png extension. Then try to modify the .lua script with a text editor. Edit and save it as a plain (ASCII) text. First of all, change all the names beginning with LM_ to your letters (uppercase). This is important because the whole lua system is a common namespace, so the unique table (= lua object) names are required. So you can call the functions and you can modify the non-local variables of the other .lua files.

You can also write scripts for the scripts menu of the menubar, in the scripts/menu/... . The scripts/utility contains the invisible parts of the programs, you can put function libraries here. Everything will be loaded automatically at the start of Moho.

The other way to run a .lua script is the layerscript. It must has a function named LayerScript() and Moho calls this function every time when renders the layer. You can load the layerscript to a layer at the Layer Settings window, General tab, when enabling the "Embedded script file" checkmark. Then a file requester appears and you can load the script into the layer. You must do this operation for every layer you want to use with the script. But if you duplicate a layer with a script, the script setting is also duplicated.

PS. I really hope in the next version there will be a function to assign a script to a layer from a lua program...
- - - Fazek
Dodgy
Posts: 207
Joined: Sat Jan 13, 2007 8:01 pm
Location: Sydney
Contact:

Post by Dodgy »

<cross post>
I would like to see the layers script references in the anme file just be the script file name, rather than the whole path, as this stops scenes being easily portable from one artist to another. If the script exists somewhere in the Scripts folder in the AS directory, AS should find them and load them. This means all scripts should have a different name, but I think it's very rare that two names will be the same (don't they have to be all different names anyway?)

As it is, if user A keeps AS in B:\Art\Anime Studio, and use B keeps AS in P:\anime Studio pro, then all layer_script references in scenes swapped between them will be wrong.
Post Reply