Tighern McDonnell Posted December 9, 2012 Posted December 9, 2012 Ok so have a very basic interaction script going. Object A is listening for string on channel x. When it hears it from Object B being touched, Object A then have three llSay lines to spit out... how to I make it so that they stay in order? I looked bout could not find a "wait" function. Maybe I am over looking something very simple. Thanks.
Rolig Loon Posted December 9, 2012 Posted December 9, 2012 You can't guarantee the order in which the lines are said. They should come out in the proper order --- the order in which they appear in your code --- every single time, but when the sim's server is lagging, the order can get scrambled. You have no control over chat lag. The best you can do is build a deliberate delay in, by having the lines spit out from a timer event that loops, say, once a second, and hope that chat lag isn't so bad that it overwhelms even that result. listen(integer chan, string name, key id, string msg){ if (name == "B") { llSetTimerEvent(1.0); gCount = -1; // Be sure gCount is global; }}timer(){ llSay(0, llList2String(messages,++gCount)); if (gCount == 2) { llSetTimerEvent(0.0); }} Then you put your three lines of output into the list named messages.
Xiija Posted December 10, 2012 Posted December 10, 2012 the LSL wait function is llSleep(). //Say(0,"message one"); llSleep(2); llSay(0,"message 2");
Rolig Loon Posted December 11, 2012 Posted December 11, 2012 But beware that llSleep does exactly what it says. It puts your entire script to sleep for that interval. It will not respond to stimulae (chat messages, touch events, sensor input ....). By contrast, a timer event only fires when the specified time interval has elapsed. Until then, the script will respond to all normal stimulae.
Innula Zenovka Posted December 11, 2012 Posted December 11, 2012 I agree with Rolig; llSleep is a dangerous function to use unless you're sure that you really want to disable the script for a while. Sometimes you do, of course, but usually a timer is what's really needed, even though it's a bit more to set up. My rule of thumb is if I'm contemplating sleeping a script for much longer than 0.5 seconds I'm probably doing it wrong.
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now