PDA

View Full Version : Trying to make my first lscript



Carm3D
11-20-2008, 04:14 PM
Hi,

I am trying to write my first lscript. I want a script that does the following:

Query Lightwave for the current time
Create a keyframe for the current item at the current time
query the current frame
GoToFrame (Current frame)

Basically I am doing some fancy expression stuff that doesn't update in realtime. So when I move a controller I just hit the FKey for this script and the display updates.

I tried looking up help in the lscript documentation, but when I load the 295kb pfd, it displays page 1 of 1; the cover page. :(

Can someone help me out either with the commands I'll need to use, or where to download lscript documentation that displays properly?

Thanks!

dballesg
11-20-2008, 04:16 PM
Hi Carm,

You can download the LScript documentation from here:

http://www.newtek.com/lightwave/developers.php

David

Carm3D
11-20-2008, 04:32 PM
Thanks David.. Got them.

Would it be possible to have a script triggered once I let go of a controller? I guess something that "listens" for a certain item to be modified.

ercaxus
11-20-2008, 04:36 PM
Thanks David.. Got them.

Would it be possible to have a script triggered once I let go of a controller? I guess something that "listens" for a certain item to be modified.
Look for master scripts in documentation and go to Dodgy's website (http://mikegreen.name/) for online docs.

Carm3D
11-20-2008, 04:38 PM
Sweet.. Thanks!

Carm3D
11-21-2008, 04:32 PM
Well I have been looking through the docs and havn't yet found a way to ask Lightwave what frame it's on. Any hints?

evenflcw
11-21-2008, 04:42 PM
Through the scene object agent.

time = Scene().currenttime;

Carm3D
11-22-2008, 10:41 AM
Thank you for your help everybody.. I've created my first lscript. :)

It doesn't create a keyframe yet. It looks like that might be more complicated.

//-----------------------------------------
// RefreshFrame
// by Carmen Rizzolo - www.Carm3D.net
// Goes to the current frame,
// essentialy refreshing any fancy IK stuff that
// doesn't update in realtime.

@version 2.1.1
@warnings
@script generic

generic {

Scene();

TimeVar = Scene().currenttime;
FrameSpeedVar = Scene().fps;

FrameVar = TimeVar * FrameSpeedVar;
GoToFrame (FrameVar);
}

evenflcw
11-22-2008, 11:34 AM
The first line:

Scene();

is redundant. All this function does is return a scene object agent. And you're ignoring that returned value. But you could have assigned it to a variable:

var scene; //unecessary declaration.
scene = Scene(); //initiation.

and then used it as such:

TimeVar = scene.currenttime;

This might save a nanosecond or two. Often people create such a variable globally so it's accessible from any function. Personally I don't bother anymore. When you've got alot of user defined functions (in a library) then you don't want to have to pass that variable around as an argument all the time nor do you want to have to set up a global variable with a specific name for each and every script. So in short... just get rid of the first line, because it fills no purpose.

Carm3D
11-22-2008, 11:44 AM
It serves -some- purpose, because the following line didnīt work without it.. But I will reword it in the method you suggest. Thanks! :)

evenflcw
11-22-2008, 01:18 PM
That seems odd. Oh well. If it works...