View Full Version : Channel modifier lscript runs twice (or more)?
bartrobinson 08-29-2005, 03:41 PM Hey folks,
I've hit a bit of a development roadblock. I'm working on a channel modifier lscript for tire rotation. It uses the store/recall functions to keep track of distance traveled inbetween frames. My problem is that it seems the lscript gets run at least twice, if not many more times each frame. I can provide code if no one has any clues right away. Thanks. The lscript will be freely available when I'm done. Thanks ahead of time.
| |
NanoGator
08-29-2005, 03:49 PM
bartrobinson: One thing you can do is have a global variable that stores the time. Then have the script check the current time against the global time. If it is different, then execute the operation and record the new time to the global variable. Something like this:
CurrentTime = nil
FunctionName
{
scene = scene();
CT = scene.currenttime;
if(CT != CurrentTime)
{
.. code for the distance stuff you mentioned
}
CurrentTime = CT;
}
(Note: I just wrote that off the top of my head.)
Lemme know how it goes. :)
bartrobinson
08-29-2005, 03:53 PM
Thanks! I'll give that a shot. I actually thought of that yesterday, but forgot before trying to implement it. Now since you came up with the solution so quickly, does that mean you have had this problem too? Is it documented by Newtek?
NanoGator
08-29-2005, 05:00 PM
Thanks! I'll give that a shot. I actually thought of that yesterday, but forgot before trying to implement it. Now since you came up with the solution so quickly, does that mean you have had this problem too? Is it documented by Newtek?
Well.. not exactly. Different types of scripts in LScript give you different events to access. Custom Item, for example, will call a function when darned near anything happens in Layout. (I've found this useful for writing motion'esque plugins that need to create keyframes.) Unfortunately, these events are rarely designed with my particular interests in mind, so I've had to be creative about how to make them work in my favor. So things like checking to see if the value is different before running came about. This is a habit I've gotten into.
So, to answer your question, I haven't reported anything like that to Newtek. I haven't worked much with Channel Modifier scripts, but I can tell you that the first thing I'd check is to see if moving other items in the scene is causing the script to refresh. That would make a degree of sense. Layout would have to stay up to date with the locations of all its objects. And, if it queries them, it probably runs the script just to be sure it's in the right place. If I'm right, that'd mean that the behavior you're seeing is by design.
:)
CGTalk Moderation
08-29-2005, 05:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2008, Jelsoft Enterprises Ltd.