Embedded Scripts

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

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
Lost Marble
Site Admin
Posts: 2347
Joined: Tue Aug 03, 2004 6:02 pm
Location: Scotts Valley, California, USA
Contact:

Embedded Scripts

Post by Lost Marble »

With the release of Moho 5.2, it is now possible to embed a script in a Moho layer. As the animation plays back, this kind of embedded script will be evaluated at each frame. This feature is brand new and kind of experimental - let's see what kind of interesting uses Moho script writers can come up with.

To create an embedded script, just create a new lua file with one function:

Code: Select all

function LayerScript(moho)
end
The "moho" object is just like the moho object you have access to in other script types. The moho.layer object is the layer the script is attached to.

To actually attach the script, double-click the layer in the Layers window to bring up the Layer Settings dialog, and click the "Embedded script file" button.

Here are a couple samples: First, a script that adjusts the angle of a bone so that it always points downward, regardless of anything else going on with its parent bones or in the layer itself:

http://www.lostmarble.com/misc/hanging.zip

Notice that the script file remains an external file, just like an image or sound file used by Moho. In this example, the script looks for any bones named "Dangler" and adjusts their angles to point downward at all times.

Next example:

http://www.lostmarble.com/misc/targeting.zip

In this example, the script is attached to the "Scripted Group" layer. As the animation plays back, the script adjusts the angle of this layer so that it points towards another layer in the project, named "Target". No key frames are created in either of these scripts - instead, the scripts dynamically change the orientation of an object. So, if you changed the movement of the Target layer, the Scripted Group layer would automatically track the new position of the target.

(This second example could quite easily be modified to make the layer follow the movement of the camera instead of another layer.)
User avatar
Hiddicop
Posts: 250
Joined: Sun Nov 07, 2004 4:18 pm
Location: Sweden

Post by Hiddicop »

Wow, this is great! Many, many thanks - the whole 5.2 update is wonderful, and especially this "embedded script"-feature!
User avatar
Hiddicop
Posts: 250
Joined: Sun Nov 07, 2004 4:18 pm
Location: Sweden

Post by Hiddicop »

And HEY! Might this be the solution to the lighting-problem? Could one make a script that makes and object invisible when it gets in contact with another object? If I have a particle-layer that shoots light-balls in all directions, could I set these light-balls to get invisible when colliding with a object? An object named "light" gets invisible when colliding with an objecjt named "wall". Is this collision-detection possible, or can you only detect the position of the orgin-point of the wall, and not the shapes in the layer?
User avatar
Lost Marble
Site Admin
Posts: 2347
Joined: Tue Aug 03, 2004 6:02 pm
Location: Scotts Valley, California, USA
Contact:

Post by Lost Marble »

This might be possible. However, to be honest, I don't know how embedded scripts will interact with particle layers. In this case, you would probably apply the script to the individual particle, and when the script gets called you could test the location of the particle and do something based on that position (make it invisible, change its color, bend it in a different direction, etc.).
User avatar
Rai López
Posts: 2228
Joined: Sun Aug 08, 2004 1:41 pm
Location: Spain
Contact:

Post by Rai López »

Oh, yeah: :shock: WOW! :shock: ...I can't believe it yet!!! The long wait REALLY have be worth reading :D :D :D ...HOM MANY NEW FEATURES!! HOW MANY bug FIXEDS! HOW MANY IMPROBEMENTS!!! (And little details TOO :D) GREAT UPDATE without any doubt! THANK YOU VERY MUCH LM for all that work! I can't believe yet that only you can do all that MARVELOUS things... *CIAO*

PS:for me, this kind of Embedded scripts (INCREDIBLE NEW FEATURE) it'd be PERFECT for Collision and for automatic contact character/ ground during walking and animation too (WITH REAL TIME ADAPTATION IF THE GROUND CHANGES!), I can think too in a ship in a waved sea, cars with auto-calculated wheel rotation... and in a thousand of aplications! I can't wait to see what kind of things can do with it 7feet and company!!! (if they have time...) :roll: *CIAO2*
Last edited by Rai López on Sun Jun 26, 2005 12:04 pm, edited 3 times in total.
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

I suspect that I'll make some time. I haven't looked at the examples yet, but I can think of any number of things to do. Thanks a ton, LM. This is way cool. Also thanks for the "assign soundtrack" bit, I think I'll work on the audio mixer first.

To throw in a small request, I'd like to ask for one more animation channel that would just be provide a place to put keyframes to trigger events that wont change any other properties of the layer. Perhaps with a user input-able number variable attached to it, defaulting to zero. This could, for one, allow you to insert variables that could be read by the embedded scripts, giving you more ways to control things, e.g. avariable angle offset for the dangle script, a tolerance or strength for collision detection or gravity, etc. I think that could be a very handy addition. Just a thought.

The default interpolation type, as well as the icons - great addition. I mean, really everything. A good compedium out of the wish list.
User avatar
BA
Posts: 196
Joined: Tue Mar 08, 2005 7:28 pm
Location: Griddleville
Contact:

Post by BA »

IMHO, script of the year award would go to the person who creates a solid ground layer that feet would stick to...
User avatar
Rasheed
Posts: 2008
Joined: Tue May 17, 2005 8:30 am
Location: The Netherlands

Post by Rasheed »

In variable degrees, that is, from really sticky like glue to somewhat adhesive.
User avatar
7feet
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.
Contact:

Post by 7feet »

Hmmmmm... Contemplating.
User avatar
Rai López
Posts: 2228
Joined: Sun Aug 08, 2004 1:41 pm
Location: Spain
Contact:

Post by Rai López »

BA wrote:a solid ground layer that feet would stick to...
:?: :?: :?: What that it means? I cant understand... :( Somebody can explainme in other words, :arrow: PLEASE?
User avatar
BA
Posts: 196
Joined: Tue Mar 08, 2005 7:28 pm
Location: Griddleville
Contact:

Post by BA »

you'd have a 'ground' layer (which could be a straight line, a flat plane, or whatever... maybe a path even), and this would have the 'sticky' script embedded...

then you could assign certain bones (ie feet) to stick to the layer automatically (with the option to turn stickiness on and off for each bone individually).

when a bone is stuck to the ground, it would be locked in place, either perpendicular or parallel to the ground...

SO: when you drop a character into your scene, it would automatically lock itself to the ground plane/path. As a default, it would be stuck to the ground - but you could un-stick each toe and heel bone for your puppet to take steps, jump, etc... then lock it back to the ground. I think this would make character animation easier and more solid.... and hopefully solve the peristent locked bone wiggle problem.


of course... i have no idea whether or not this would be possible.
Last edited by BA on Fri Jul 08, 2005 10:25 pm, edited 1 time in total.
User avatar
Rai López
Posts: 2228
Joined: Sun Aug 08, 2004 1:41 pm
Location: Spain
Contact:

Post by Rai López »

Uff... THANK YOU! It'd be a DREAM!!! :D Mmm... But this seems SO much complicated :( isn't? ...I was thinking in a script that do the character follow a certain group of points called "ground" (i.e.) for the character (or car, or ship) adapts his movement to the ground variations... Not so sophisticated but more easy to do (I think) ...Anyway, I'd be bery happy to see any new embedded script (ANY), because I LOVE the feature possibilities but I still can't take advantadge of it... :( CIAO!
janimatic
Posts: 136
Joined: Sat Mar 26, 2005 12:22 am
Contact:

Post by janimatic »

hey!

i didn't had much time playing with moho lately, i was doing some music video in maya/shake,
but i just came and saw this long waited new feature!!
Great for character setup! (let's see if lua doesn't slow things down too much)

i just wanted to say thank you and bravo LM!

regards
janimatic
Posts: 136
Joined: Sat Mar 26, 2005 12:22 am
Contact:

Post by janimatic »

too bad i am so busy

i am astonished noone gave any feedback about this amazing feature though!

i'll be back soon!
User avatar
Rai López
Posts: 2228
Joined: Sun Aug 08, 2004 1:41 pm
Location: Spain
Contact:

Post by Rai López »

Seems that ALL Moho scripters ase SO busy... WHAT A PITY!!! :cry:
Post Reply