Jump to content

Say Once?


FluffyEscapes
 Share

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

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

Recommended Posts

Hello everyone I realize I'm really really really new to SL but ther eis something I'm trying to do and not having much luck.. I understand collision_start etc but I cannot for the life of me figure out how to do this

 

I am trying to make a script so that when someone steps on an object it sends a message.. however I only want this to happen once a day per person ... 

 

I'm totally lost heh :( 

Link to comment
Share on other sites

THis is what I have so far

 

integer type;
list MessageList;
default
{
state_entry()
{
llVolumeDetect(TRUE);
llSetTimerEvent(86400);
}
collision(integer detected)
{
type = llDetectedType(0);
if(type == 3){
if(~llListFindList(MessageList, [llDetectedKey(0)]))
{
llRegionSayTo(llDetectedKey(0),0,"HEYYOU!");
MessageList+=[llDetectedKey(0)];
}
}
}
timer()
{
llOwnerSay("RESET!");
}
}

Link to comment
Share on other sites

That's a two-part challenge, not too hard.  You'll have to have a way to save the names or UUIDs of everyone who steps on your object, and you'll have to have a way to remove them from your saved list after a day has passed.  Create a global list.  At each collision, check first to see if the person is already on the list.  If not, add him, and make note of the time (either in a parallel list or as a stride in the same list) and send your message.  If so, then ignore the person.  Run a timer that fires every couple of minutes.  In the timer, check your saved collision times.  If any are older than 24 hours old, delete them.

Try writing something along those lines and then post it in this thread.  It's a good project to learn on.

EDIT:  Oh, good.   You added your trial script while I was typing. 

Link to comment
Share on other sites

OK, you have the first half of the challenge figured out.  Now all you need is the timer.  You are expecting the script owner to come along and delete the entire MessageList once a day.  That works, but the guy who tripped on your object ten minutes before you reset it will get the same message if he comes around ten miinutes later.

Try creating an second list, MessageTimes, and storing llGetTime() everytime you save a UUID in MessageList.  Then, instead of setting your timer event to 86400 seconds, set it to, say, 120.  And each time it fires, read entries in the MessageTimes list.

if (llGetTime() - llList2Float(MessageTimes,i) > 86400.0){    MessageTimes = llDeleteSubList(MessageTimes,i,i);    MessageList = llDeleteSubList(MessageList,i,i);}

 

 

  • Like 1
Link to comment
Share on other sites

Hiya, Fluffy, and welcome to the Scripting Forums.   

A point about llDetectedType -- and I really would suggest you read the wiki article, since it shows you how to deal with multiple collisions (which might well be in issue in this example) --  is that it's a bitwise comparison, like this:

if(llDetectedType(0)&AGENT_BY_LEGACY_NAME){			//it's an avatar		}

 That's because, as the old LSL wiki explains,

 

Since multiple values can be returned by functions relating to object type, code like this won't work:if (llDetectedType(i) == AGENT)So use a test like:if (llDetectedType(i) & AGENT)

 

  • Like 1
Link to comment
Share on other sites

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