PDA

View Full Version : question



PentaSeiler
10-13-2003, 09:57 AM
Iím new to LScript and having trouble. I would like to either build a motion path in Modeler or an animation for Layout. However, I would like to read the position data from an external ascii file. I am unable to use many of the file commands in Modeler and I canít figure out how to increment the frame in Layout in my loop to read the data and set the position. Do you have any suggestions as to how I might do this or is this task even possible?

fxnut
10-13-2003, 03:33 PM
Okay, first task - to read in an ASCII file.

Well. if you haven't looked at the LScript Reference PDF file you should. Specifically, have a look at the File() command on page 5. Then have a look at the File Object Agent in chapter 13 (page 129). There should be plenty of information there to let you do this. But you said you were unable to use the file commands in Modeller; what do you mean? Didn't they work?

For creating a motion path in Layout, don't try to set key frames by manually changing the current key slider and moving objects. Just directly manipulate the XYZ and HPB channels of the object. You'll need to use the Channel Group Object Agent, and the Channel Object Agent to access the keyframes of the object's motion. Again, all this information is in the Reference Manual.

Have a look at the examples in the scripts directory. There're plenty of scripts there you can adapt to your own purpose, and they're always handy to use as reference for syntax and structure.

Any other problems, I'd recommend posting your code up here - then we might be able to see what the problem is.

Regards

Andy

PentaSeiler
10-13-2003, 09:33 PM
Thanks for the reply. I apologize for not being more thorough in my first message. I have both the Lscript documentation files and have looking over them intently.

In answer to your question, no, they didn't work in modeller.
I could open a file, but if I tried to read from it, or really use any method, I got an error stating "invalid object method" I had a while loop with the condition (!objfile.eof()) and received an error stating "invalid object method eof()".

I have been checking out the channel object agent methods and motion scripts. Again I've been getting the same error. Maybe my code is incorrect, but best I can tell from the documentation, this ought to work. Here is a small piece of test code.

@warnings
@script channel
@name Rotation


create: channel
{
setdesc("Rotation");
}

process: ca, frame, time
{
ca.createKey(10,10);
ca.createKey(20,15);
ca.createKey(30,20);
ca.createKey(40,25);
ca.createKey(50,30);
}


When I go into the graph editor, I select a rotation channel of my object, go to the Modifiers tab, Add Modifiers, LW_Lscript, load this code and I get an error message that says "invalid object method createKey().":rolleyes:

Is there a debugging environment for Lscript?

Again, thanks for the help.

fxnut
10-14-2003, 06:05 AM
Originally posted by PentaSeiler
In answer to your question, no, they didn't work in modeller.
I could open a file, but if I tried to read from it, or really use any method, I got an error stating "invalid object method" I had a while loop with the condition (!objfile.eof()) and received an error stating "invalid object method eof()".
Hmm, sounds like your file object might be "nil". You'll need to check it in the debugger (see below).


[I have been checking out the channel object agent methods
...<snip>
process: ca, frame, time
{
ca.createKey(10,10);
....<snip>

Don't do this. The process() UDF gets called numerous times every frame. You should really create a "Generic class" plugin, and use that to load in the motion file. Also, the "ca" parameter to the UDF is not a Channel Object Agent, so that's why your createKey call isn't working, but like I said, you shouldn't be trying to do it this way.

As an example, here's some skeleton code showing you how to go about doing what you want.


@version 2.6
@warnings
@script generic
@name Motion Loader

generic
{
//Load and parse your motion file here

//Find channels (finding x channel as an example)
group = ChannelGroup("MyObject");
curChannel=group.firstChannel();
posxChan=nil;
while(curChannel)
{
if (curChannel.Name="Position.X")
{
posxChan=curChannel;
}
curChannel=group.nextChannel();
}

//Create the keys in the channel here
posxChan.createKey(0.2,1.0);

}



Is there a debugging environment for Lscript?
Yes, just enter the command "debug();" into your script. Try not to call it more than once if you can help it, as every call will open a new debug window (it's a real pain that!!!).

PentaSeiler
10-15-2003, 10:33 AM
Thanks for the help. My script is working beautifully. Your comment on the error message I was receiving helped me figure out my problem. I was using a backslash in my file directory name instead of a forward slash and the compiler wasn't recognizing the backslash. Therefore I wasn't getting an object.

Thanks again.