Jump to content

Sleep One Line, Not Entire Script


Rich Reynaud
 Share

You are about to reply to a thread that has been inactive for 4551 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello,

I'm trying to find a way to pause or sleep a single line within a script while the remainder of the script continues to run. Here's a basic description of the script:

1) Code to play a sound.
2) Code to rotate a prim in one direction.
3) Code to rotate the same prim in the opposite direction 4 seconds later.
4) Code to continue playing remaining sounds in order.

I need to be able to pause line three for 4 seconds without pausing line four and everything below it. Is this possible? I haven't been able to locate a function to do this.

Regards,
Rich

Link to comment
Share on other sites

I can't imagine what problem you'd have with it but there certainly aren't any straightforward ways to delay execution of a single in-line command.

If you have MAJOR trouble you could always split the rotation out to a child script with a built-in 4s delay, then use a linked-message to tell it when to start.

Link to comment
Share on other sites

This is a good place to point out that mastering syntax is the easiest part of learning to script.  The hard part is logic, and that is almost independent of the scripting language and its syntax.  Map out (on paper if necessary, but at least in your head) what the path from your starting point to the finish line has to look like.  Where are the decision points along the way?  What will happen at each of them if the user makes a different choice or if the script's environment changes?  What pieces of information will you need in order to make decisions at each of those points?  How will you know when you have reached them?  If you can create a logical map that answers those questions, finding the syntax to describe the map is relatively simple.

In this case, remember that LSL is an event-driven language. Actions in the environment trigger events, and all actions take place in those events.  Once a timed event is triggered, the action that occurs happens in the timer event.

Link to comment
Share on other sites

Assuming you know how to accomplish everything but the delay, try looking at the list like this:

 

1)  Code to play a sound

2)  Code to rotate a prim in one direction

3)  Code to start a timer with a 4 second duration (timer code has the code to rotate the prim in the opposite direction)

4)  Code to continue playing remaining sounds in order.

 

There will be no (significant) delay between executing step 3 and step 4, but when 4 seconds has passed, the code in the timer will be executed.

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4551 days.

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
 Share

×
×
  • Create New...