Where do I start from?

QaQ

New member
I'm interested in learning Lscript but I've no idea where should I start from. There are no (Official) tutorials , nor any video courses .:(:(
 

Kryslin

Active member
In your Lightwave folder, there is the SDK Folder. There should be an lscript archive, that should contain the original documentation. The first exercise is replacing the weld tool, which use to have an annoying popup at the end you had to click through.

lScript is very C like. Every line ends in a ";". Scripts differ between modeler and layout. However, you'll probably only deal with modeler scripts (main {...} ) and layout generic (generic {...} ).

Here's the aforementioned weld script...
Code:
@script modeler
@warnings off
@name Weld Points

main
{
    selmode(DIRECT);
    pntCnt = pointcount();
    if(pntCnt == 0 ) error("No points selected!");
    editbegin();
    lastPntPos = pointinfo(points[pntCnt]);
    for(currPnt = 1; currPnt <= pntCnt; currPnt++)
    {
        pointmove(points[currPnt],lastPntPos);
    }
    editend();
    mergepoints();
}

And here's an invaluable guide : http://www.mikegreen.name/Lscript/Lscript Index.html

Above all, ASK Questions. And look through the scripting forum. And keep in mind that the documentation for lscript is in a poor state, having been ill maintained for many years. You may have to work out your own solutions.
 

Kryslin

Active member
Where to start :
1) Have an idea. To start with, a simple task that is clearly defined.
2) What steps do you need to do to accomplish 1)? Write them down, in sequence.
3) Begin looking at commands that will accomplish each step in 2).
4) Begin debugging. The most common mistake in lscript is a missing ; at the end of the line. The debug(); statement is your friend. Repeat 4) until there are no more errors, and script functions as intended.

The first program most people write in school is "Hello World!".

1) Print "Hello, World!" On the screen.
2) this task is so simple, it does not need steps.
3) Looking through Mr. Green's lscript reference, we find the info command under messages.

So, our code for modeler would look something like this:
Code:
main{
    info("Hello, World!");
}

For layout, the code is slightly different:
Code:
generic{
    info("Hello, World!");
}

And there you go, your first script.

I would also reccomend that you learn Python. If you can't get it done in lscript, you can probably get it done in Python, which wraps the LW SDK.
 
Top Bottom