Jump to content

Sport, time and name.


Tattooshop
 Share

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

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

Recommended Posts

Hello! I’m trying to make a script for sports swimming in the pool. I think to use an invisible prim at the end of the pool and when avatar comes into contact with the object, it will llShout the name of the avatar and SL time. The pool uses SL water so avatars simply move under water. How to do it better? :)

Link to comment
Share on other sites

I assume that the actual time on the clock is not important.  What you want is the lapsed time.  So trigger llGetUnixTime when you  start the race and let your collision prim at the other end trigger it again.  Subtract one from the other and voila.

  • Thanks 1
Link to comment
Share on other sites

20 minutes ago, Rolig Loon said:

I assume that the actual time on the clock is not important.  What you want is the lapsed time.  So trigger llGetUnixTime when you  start the race and let your collision prim at the other end trigger it again.  Subtract one from the other and voila.

Thank you! :)

I am making a script for a friend and he wants it to be SLT (actually yeah a bit strange :D). Besides, he wants two messages - the swim will be there and back, I think it will be very difficult to arrange and I myself can’t imagine how to do this. I do not want to burden you. Also the problem is that the pool is huge 50 meters in length. Will the second script hear such a message?

So I use so far:

default
{
    collision(integer num_detected)
    {
        llShout(0, llDetectedName(0) + llGetTimestamp());
    }
}

BUT! The script produces too many messages on inaccurate collision. Is it possible to somehow limit one message per avatar? Like there is some kind of filter (llCollisionFilter). But it will probably be difficult, lists again...   :)

Link to comment
Share on other sites

You have several different challenges.  Rather than feeding you sample code, I'll just suggest a few things for you to investigate:

1. It's interesting that he wants a clock time rather than a lap time, but that's no problem. You can use llGetWallclock to get the time since midnight in SLT and then use a short routine like the example in the LSL wiki to convert that to hours/minutes/seconds.

2. Yes, llShout is limited to 50m, but since one script can listen to another one, you can always put relays anywhere in the area to pass messages along.

3. It's almost always wise to build in a filter to get rid of redundant collisions and, yes, that means making a list.  When your script is triggered by a collision, the first thing it should do is to figure out whether the same person has collided recently. (Well, actually, the first thing that I do is a quick filter to be sure that the collision was actually with an avatar and not a beach ball) That means building a temporary list of colliding people to check against, and then scripting a way to clear the list when you don't need it any more.  BTW, llCollisionFilter is a nice function but you can't use it to filter for multiple  hits by the same avatar.

4. I don't know why you would want to know times unless you were comparing them to something else, which is getting us back to lap time. At the very least, you need to know when the person started swimming (or should have started). That means including some sort of starting gun, a stopwatch, or something to record the start.

Edited by Rolig Loon
typos. as always.
  • Thanks 1
Link to comment
Share on other sites

3 hours ago, Tattooshop said:

So I use so far:


default
{
    collision(integer num_detected)
    {
        llShout(0, llDetectedName(0) + llGetTimestamp());
    }
}

BUT! The script produces too many messages on inaccurate collision. Is it possible to somehow limit one message per avatar? Like there is some kind of filter (llCollisionFilter). But it will probably be difficult, lists again...   :)

look into collision_start event

http://wiki.secondlife.com/wiki/Collision_start

 

  • Thanks 1
Link to comment
Share on other sites

8 hours ago, Mollymews said:

look into collision_start event

http://wiki.secondlife.com/wiki/Collision_start

 

 

11 hours ago, Rolig Loon said:

You have several different challenges.  Rather than feeding you sample code, I'll just suggest a few things for you to investigate:

1. It's interesting that he wants a clock time rather than a lap time, but that's no problem. You can use llGetWallclock to get the time since midnight in SLT and then use a short routine like the example in the LSL wiki to convert that to hours/minutes/seconds.

2. Yes, llShout is limited to 50m, but since one script can listen to another one, you can always put relays anywhere in the area to pass messages along.

3. It's almost always wise to build in a filter to get rid of redundant collisions and, yes, that means making a list.  When your script is triggered by a collision, the first thing it should do is to figure out whether the same person has collided recently. (Well, actually, the first thing that I do is a quick filter to be sure that the collision was actually with an avatar and not a beach ball) That means building a temporary list of colliding people to check against, and then scripting a way to clear the list when you don't need it any more.  BTW, llCollisionFilter is a nice function but you can't use it to filter for multiple  hits by the same avatar.

4. I don't know why you would want to know times unless you were comparing them to something else, which is getting us back to lap time. At the very least, you need to know when the person started swimming (or should have started). That means including some sort of starting gun, a stopwatch, or something to record the start.

Thank you both a lot! It worked! :D

string ConvertWallclockToTime()
{
    integer now = (integer)llGetWallclock();
    integer seconds = now % 60;
    integer minutes = (now / 60) % 60;
    integer hours = now / 3600;
    return llGetSubString("0" + (string)hours, -2, -1) + ":" 
        + llGetSubString("0" + (string)minutes, -2, -1) + ":" 
        + llGetSubString("0" + (string)seconds, -2, -1);
}

default
{
    collision_start(integer num_detected)
    {
        llShout(0, llDetectedName(0) + " " + ConvertWallclockToTime());
    }
}

 

  • Like 1
Link to comment
Share on other sites

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