Jump to content
Sign in to follow this  
Rich Reynaud

Sleep One Line, Not Entire Script

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

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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.

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...