List of available functions?

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
mkelley
Posts: 1647
Joined: Fri Nov 02, 2007 5:29 pm
Location: Sunny Florida
Contact:

List of available functions?

Post by mkelley »

This is driving me crazy -- I've found the Lua reference sites and understand the language (nothing particularly new there), but without a list of the available functions in AS it's hard to do anything useful.

I really need to write a script to key all points in a layer. I study all the scripts and can make out *some* functions, but there are many basic ones that I just can't find any reference to. I need to select all the points in a layer -- where is THAT function? I can find functions that DO things with selected points, just not any examples where one automatically cycles through all the points in a layer. I need to set a key on all the points -- I can find example functions in other people's scripts on how to set keys for bones, but no where do I find a reference for setting a key on vector points.

I downloaded the Moho documentation that LM posted early on but it only has a bare handful of functions listed (it was done years ago, and maybe even pre LUA). Am I missing something *real* obvious here?
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

The only source of information for Moho API is the mentioned LM file, this forum and the examples of other people. Look for ancient posts from fazek. It has some hits on programming. Also 7feet.

Best
-G
myles
Posts: 821
Joined: Sat Aug 21, 2004 3:32 am
Location: Australia, Victoria, Morwell
Contact:

Post by myles »

The initial documentation here should get you started, along with a decent Lua reference and reading through the sample scripts provided.

Some further functions are documented in the new release announcements, e.g. see the Scripting section of version 5.3 release notes.

I've got an antique modification to the API script here which goes trawling through the API looking for functions and values. However, it doesn't provide function parameters - sometimes you have to look in the existing tool and menu scripts to get an idea of these.
That version outputs to a .html file (provide the extension as well).

Looking through its output I can tell you you need to use the SelectAll function which is the member of an M_Mesh object.
Reading through the lm_autoweld.lua sample script, I see you can get that by calling Mesh(), which seems to be part of the ScriptInterface object/table.

without testing, something like:
local mesh = moho:Mesh()
mesh.SelectAll()

Regards, Myles.
"Quote me as saying I was mis-quoted."
-- Groucho Marx
User avatar
mkelley
Posts: 1647
Joined: Fri Nov 02, 2007 5:29 pm
Location: Sunny Florida
Contact:

Post by mkelley »

Thanks Myles. That's very helpful. I guess I'll have to start digging through all that stuff.

I do appreciate the specific headsup for the mesh points -- I think I can stumble around and get the right syntax there. I don't suppose you have even a guess as to setting the keys for the points?

I know that user programmable interfaces tend to be the least documented of any program's features, but it's too bad more time wasn't spent on this because a whole lot of very useful stuff could be done with it.
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

I don't suppose you have even a guess as to setting the keys for the points?
If you use "SetValue" on the animation value of a point it creates a key frame.

For example this is from Genete's code:

Code: Select all

		   for i=0, mesh:CountPoints()-1 do --- move the points.
			  local pi=mesh:Point(i)
			  local pimoved =LM.Vector2:new_local()
			  pimoved:Set(0,0)
			  for k=1, maxposes do
			  local pospik=pi.fAnimPos:GetValue(k)
				 pimoved = pimoved + pospik*w[k]/wtot
			  end
			  pi.fPos:Set(pimoved)
		   end

pi.fPos:Set(pimoved) just sets the points new position. Changing the fPos doesn't add a key frame. BUT if you did this:

Code: Select all

pi.fAnimPos:SetValue(when, pimoved)
It would create a key frame for that point. "when" is the frame to set the value. You can just put in a number or variable or if you just want the current frame use moho.frame.

-vern
User avatar
mkelley
Posts: 1647
Joined: Fri Nov 02, 2007 5:29 pm
Location: Sunny Florida
Contact:

Post by mkelley »

Thanks, Vern. I appreciate this greatly.
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

I use "fPos" more so than "fAnimPos" because I don't need all the keys for my scripts. Unfortunately there are some things that can't be changed unless you put in a key. Some things only have an AnimVal.

Also, some things don't even have an AnimVal. like point width. No AnimVal even though it can be animated. This means you can only set the value on the current frame. You can still key this by forcing a key frame for that channel... can't remember how to do it though off hand.

I keep pestering poor Mike to add ALL the properties to ALL of the elements just so it's consistent. I have my fingers crossed for the long awaited "update". ;)

-vern
human
Posts: 688
Joined: Tue Jan 02, 2007 7:53 pm

Post by human »

Can I assume that AS is written in C++?

If it were ported to Java, wouldn't it be a hell of a lot easier to make improvements?
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

human wrote:Can I assume that AS is written in C++?

If it were ported to Java, wouldn't it be a hell of a lot easier to make improvements?
Oh please.. I couldn't use AS as a Java app. It might be easier to make improvements but running in java would be a nightmare. Every Java app I've ever used was a dog. I haven't seen one that runs "smoothly". Maybe I'm not using the right ones though.

I don't see it happening though. Yes as far as I know AS is done in C++ or some variation of it and I don't think it will get ported anytime soon. Besides wouldn't that put it in the "open source" category?

-vern
human
Posts: 688
Joined: Tue Jan 02, 2007 7:53 pm

Post by human »

heyvern wrote:Every Java app I've ever used was a dog. I haven't seen one that runs "smoothly". Maybe I'm not using the right ones though.
Oh, man, you are so 1995. 8) *

It's 2008, get with the programming.

MovieStorm is written in Java, as far as I know.

It pushes 3D humans around a 3D set in real time.

AS is just vectors!

PS Besides, Java's Batik "Squiggle" browser can animate SVG morphing in 3D parallax space, as I recently demonstrated.

http://generalpicture.com/walt/?p=53

(You need to install the Java Batik package to see the crude demo.)

* My apologies to "English as a second language" readers. "You are so X" is an idiom. It means" "You are trapped in condition X."

Therefore, "You are so 1995" means "You are still thinking about the slow performance of Java as we knew it in 1995."
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Aren't all Java applications open source? Isn't the source code "open" when you download it?

I guess I have problems with hit or miss functionality depending on which version of Java I'm using (I'm on a Mac).

-vern
F.M.
Posts: 497
Joined: Thu Nov 04, 2004 4:29 pm
Location: Between my ears

Post by F.M. »

Human wrote:
If it were ported to Java, wouldn't it be a hell of a lot easier to make improvements?
Let's not put our chickens before the cart :lol: . I think we should demand Moho AS 6(shelved) be released before any porting takes place!
"and then Man created god!"
Post Reply