LScript Notes

The LScript documentation I got with LightWave 7.5
was pretty feeble. It was enough to get started, but
there's a lot that is missing, slightly misleading.

LANGUAGE & FUNCTIONS

The language construction is almost exactly C-like,
generally. Functions look like this:

no_argument_function
    {
    return result;
    }

function_with_arguments : arg1, arg2, arg3
    {
    return arg1 + arg2 + arg3;
    }

PRIMITIVE DATA TYPES

LScript variables spring into existence as needed.
They can be one of several types. There is no
"struct" type though.

There doesn't seem to be any way to find out what
type a variable is.

NUMBER and STRING Numbers and Strings act much like
they do in Perl. You can use '+' to concatenate
strings. I've noticed that sometimes "string math"
as they call it fails inside function arguments. If
in doubt, compute it first and pass in the result.

ARRAY Arrays are indexed starting at 1. You can quote arrays
with @-signs.

    my_array[1] = "first element";
    my_array = @"element one",2,3,4,"element 5"@;

UV coordinates are passed as two-element arrays.

VECTOR This is specific for graphics. Vectors have
three elements, x, y, and z.

    my_point_v.x = 3;
    my_point_v = <3,4,5>;
    my_point_v = p1v + p2v - p3v; // other vectors
    my_point_v *= 1.7;            // scale by numbers




BROKEN ROUTINES

As near as I can tell,

    rempoint(), and
    rempoly()

just plain do not work! How sad.


UNDOCUMENTED ROUTINES

    loadimage(file_path_to_image)

returns an image object agent if the file is found. The name
of the new image will be the last part of the file path.

    clearimage(?)

Not sure what the arguments are. It is not in the manual,
but is mentioned in passing in some beta release notes I
found by google.


QUIRKY VERSIONITIS

    editbegin() vs reqbegin()

On my Mac at home, I could open up a requester while
in Mesh Edit mode (editbegin()), and it worked fine.
But on my friend's Windows version, LightWave gave
an error box saying "Illegal reqedit() in Mesh Edit
mode." It was necessary to go back to Command
Sequence mode (editend()) before reqbegin() or
getvalue(control) would work.