Page 1 of 1

List of available functions?

Posted: Sat Feb 02, 2008 5:34 pm
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?

Posted: Sat Feb 02, 2008 5:37 pm
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

Posted: Mon Feb 04, 2008 1:13 am
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.

Posted: Mon Feb 04, 2008 7:19 pm
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.

Posted: Mon Feb 04, 2008 8:21 pm
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

Posted: Mon Feb 04, 2008 9:03 pm
by mkelley
Thanks, Vern. I appreciate this greatly.

Posted: Mon Feb 04, 2008 9:16 pm
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

Posted: Mon Feb 04, 2008 10:25 pm
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?

Posted: Mon Feb 04, 2008 11:56 pm
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

Posted: Tue Feb 05, 2008 12:53 am
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."

Posted: Tue Feb 05, 2008 6:30 am
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

Posted: Tue Feb 05, 2008 3:58 pm
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!