Thread: Lscript anyone?

Reply to Thread
Results 1 to 9 of 9
  1. #1 Lscript anyone? 
    Join Date
    May 2009
    Location
    Los Angeles, CA
    Posts
    149
    Is there anyone on this board who happens to be fluent with Lightwave's Lscript? I occasionally dabble into it, and I always seem to run into one thing or another that just plain doesn't work the way I thought it would. And useful information about Lscript online is practically non-existent except for Mike Green's Lscript index, and the occasional tutorial or sample code where you're lucky if it actually helps you solve a specific problem.
    [ Nuke | AE | Lightwave ]
    "Study your math. Key to the universe."
    Reply With Quote  

  2. #2  
    Join Date
    Mar 2010
    Location
    Los Angeles, CA
    Posts
    5
    I know some lscript, was there something specific you were having trouble doing?
    Reply With Quote  

  3. #3  
    Join Date
    Oct 2007
    Location
    Now in K-Town, Los Angeles
    Posts
    460
    I used to hack L-Script back in the days of LW 6.0, so I feel your pain. It always seemed like there was just not quite enough information out there to figure how exactly to do what you wanted.
    I never seem to notice 'visitor' messages until months later. In theory, a PM should email me to let me know I have a message.
    Reply With Quote  

  4. #4  
    Join Date
    May 2009
    Location
    Los Angeles, CA
    Posts
    149
    @chrispeterson: Whatever question I had in mind at the time I've figured out, but every time I use a new piece of code I haven't used before, I seem to get tripped up with how it's supposed to work. Like I wrote this script that makes an array of nulls and loads a bunch of instances of an object, parent each to the nulls, all with a for loop.

    That worked fine, but then I wanted to scale up or rotate the object by some fixed amount after parenting. It works on the very first object, but none of the others. They load normally, but with no change in their scale or rotation. Could this be because I'm not telling the script to select that object? I assumed it always selected the last created object/null/camera/etc.

    @forkazoo: Definitely like banging your head against a wall sometimes. It's becoming a bit more intuitive, but I always seem to get snagged by something that doesn't work the way I thought it did. I really would like to learn more serious programming and make real plug-ins for Lightwave. Do you still use Lightwave or something else now?
    [ Nuke | AE | Lightwave ]
    "Study your math. Key to the universe."
    Reply With Quote  

  5. #5  
    Join Date
    Mar 2010
    Location
    Los Angeles, CA
    Posts
    5
    Can you post some of your code so I can take a look at the scaling and rotating part that you are having trouble with?
    Reply With Quote  

  6. #6  
    Join Date
    May 2009
    Location
    Los Angeles, CA
    Posts
    149
    Here's the code, minus parts that are irrelevant to make it easier to read, and with comments that tell you the way I thought it worked.

    Code:
        for(n = 0 ; n < 100 ; n++)
        {
    
            RefreshNow();
    
            // Removed some variable stuff, not making or modifying any items
    
            AddNull(newNullName); // Creates new null, presumably selecting it
            ParentItem("Center"); // Parents to null I created before loop starts
    
            LoadObject(pixelObj); // Adds object, and presumably selecting it
            Rotation(180,0,0); // Modifies the loaded object, but only works on the first loop.
            ParentItem(newNullName); // Parents to the null I just made
    
            SelectItem(newNullName); // Selects the null I made before adding the object
    
            for(m = 0 ; m <= 72 ; m++)
            {
                GoToFrame(m);
    
                // Removed some other math that just creates the values used below.
    
                Position(xP,yP,zP); // Moves the position of the new null on a particular frame
            }
        }
    When it loops back, I don't see how it could be ignoring the Rotation() command, or having the wrong item selected.
    Last edited by Loud; March 13th, 2010 at 09:33 PM.
    [ Nuke | AE | Lightwave ]
    "Study your math. Key to the universe."
    Reply With Quote  

  7. #7  
    Join Date
    Mar 2010
    Location
    Los Angeles, CA
    Posts
    5
    Ok, here is a modified version of what you gave me. I did tweak it so you can see things are getting changed (position offset on MyNull), but it should be pretty straight forward to editing it for what you need. I also commented changes I made in case you were wondering why I did something. Basically this creates a hierarchy like so:

    Center
    ....MyNull_0
    ........loadedobject.lwo
    ....MyNull_1
    ........loadedobject.lwo
    ....MyNull_2
    ........loadedobject.lwo
    etc.

    It also creates the rotation on loadedobject.lwo at frame 0 each time it loads it again. And it keys MyNull_xx at every frame between 0 and 72 with a position offset. Any other questions feel free to ask.

    -chris

    Code:
    @warnings
    @version 2.2
    @name testscript
    
    generic
    {   
    // ***Make sure autokey is on when you run this script***
    // Define Variables
     xP = 1;
     yP = 1;
     zP = 1;
     // Create the Center null
     AddNull("Center");
     // Start creation of child nulls and loaded objects
     for(n = 0 ; n < 10 ; n++)
     {
       RefreshNow();
       // Create unique item names for nulls
    	 newNullName = "MyNull_" + n;
       AddNull(newNullName);
       // Parent the new null to the Center null
       ParentItem("Center");
       // Load in the new object
    	 LoadObject("C:\\_test\\loadedobject.lwo");
       // Rotation to be applied to the loadedobject.lwo
       Rotation(180,0,0);
       // Parent loaded object to the MyNull
       ParentItem(newNullName);
       // Select MyNull
       SelectItem(newNullName);
       // Loop through frames 0-72 applying a positional change
       for(m = 0 ; m <= 72 ; m++)
       {
       	// Jump to frame m
         GoToFrame(m);
         // Apply change in position (I multiplied it by m just to see changes and make sure it was working)
         Position(xP*m,yP*m,zP*m);
       }
       // Reset the time to frame 0 so that everything is keyed at the correct frame
       GoToFrame(0);
     }
    }
    Reply With Quote  

  8. #8  
    Join Date
    May 2009
    Location
    Los Angeles, CA
    Posts
    149
    Ah, so it was because I was adding the first one on frame 0 and then all the others on frame 72. That makes perfect sense. Thanks, Chris.
    [ Nuke | AE | Lightwave ]
    "Study your math. Key to the universe."
    Reply With Quote  

  9. #9  
    Join Date
    Mar 2010
    Location
    Los Angeles, CA
    Posts
    5
    No problem, glad I could help.
    Reply With Quote  

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     
Bookmarks
Bookmarks
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts