Jump to content

Need random timer countdown script for RP


DuncanWolff
 Share

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

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

Recommended Posts

I am building a prop engine for RP.

I need a script That is touch on and off to activate.

When touched on, I need it  to  say in local chat. "Goes into hyperspace." Then states how many minutes and seconds  to arrival. It then begins silent countdown to zero. before it reaches zero it states in local chat "30 seconds until arrival"

When timer reachers zero. says in local chat. "Arrives at destination."

Each time the object is touched with this script the timer should randomly pick a start time. anywhere from 8 minutes down to 3 minutes and then countdown to zero.

This is to simulate travel time from place to place with random time in flight.

I have made several attempts at writting this on my own and have epically failed each time. Any help would be appreciated.

 

Link to comment
Share on other sites

That should be a very simple exercise.  Basically, all you're doing is using the touch_start event to trigger a timer.  The random time for the timer will be determined by

float random_time = llFrand(300.0) + 180.0;

That is, it will be a random number that is at least 180.0 seconds ( = 3 minutes) but could be as much as 300.0 seconds larger.

The only other thing you are expecting is a 30 second warning, so you actually want to set your timer for random_time minus 30.0 seconds.  Then, when the timer reaches that mark, send the warning message and reset the timer for 30.0 seconds.  When it goes off the second time, set it to 0.0 and say "arrived". Just remember to set a global integer flag when you hit the timer's first limit so that it will recognize that it's supposed to do something different the second time.

If you're new to LSL scripting, review http://wiki.secondlife.com/wiki/If and http://wiki.secondlife.com/wiki/LSL_Variables .

Link to comment
Share on other sites

I would copy and paste what i have done so far but It wont let me do it directly from in world. I have been working on this all day with no progress. My issue is probably trying to take elements from different scripts and trying to combine them. I am sure i have misplaced a } or a ; somewhere.

Is it possible for someone to write up an example of the script?

Thanks in advance. 

Link to comment
Share on other sites

Not here.  We rarely write complete scripts as "examples" here.

You should be able to copy/paste a script from anywhere into a post here.  You're probably right that you've misplaced a bracket or a semicolon.  Those are very common errors, not matter how experienced you get.  Fortunately, they are also extremely easy to catch.

I suggest using a good script editor, BTW.  The one in your viewer has crummy error messages and lacks some features that can make scripting much cleaner, including autocompletion that makes sure that you have matching brackets and a sem icolon at the end of each line of code.  Many people use LSL Editor.  I prefer Sublime Text.  You can find those and several others at http://wiki.secondlife.com/wiki/LSL_Alternate_Editors

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3175 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...