Page 1 of 3

Embedded Scripts

Posted: Fri Jun 24, 2005 10:13 pm
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.)

Posted: Fri Jun 24, 2005 11:26 pm
by Hiddicop
Wow, this is great! Many, many thanks - the whole 5.2 update is wonderful, and especially this "embedded script"-feature!

Posted: Fri Jun 24, 2005 11:34 pm
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?

Posted: Sat Jun 25, 2005 12:17 am
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.).

Posted: Sat Jun 25, 2005 12:42 am
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*

Posted: Sat Jun 25, 2005 6:52 am
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.

Posted: Thu Jul 07, 2005 7:10 pm
by BA
IMHO, script of the year award would go to the person who creates a solid ground layer that feet would stick to...

Posted: Fri Jul 08, 2005 9:10 am
by Rasheed
In variable degrees, that is, from really sticky like glue to somewhat adhesive.

Posted: Fri Jul 08, 2005 11:09 am
by 7feet
Hmmmmm... Contemplating.

Posted: Fri Jul 08, 2005 12:25 pm
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?

Posted: Fri Jul 08, 2005 5:24 pm
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.

Posted: Fri Jul 08, 2005 7:55 pm
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!

Posted: Sat Jul 16, 2005 5:34 pm
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

Posted: Thu Aug 11, 2005 6:22 pm
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!

Posted: Fri Aug 12, 2005 4:14 pm
by Rai López
Seems that ALL Moho scripters ase SO busy... WHAT A PITY!!! :cry: